Subset a data.frame according to a condition, apply a function to the rows where the condition is TRUE, then rejoin with the rows where condition is FALSE or NA. A split-apply-combine where function is only applied to a subset of rows.
Filtering expression can be either quoted or unquoted, e.g. complete.cases(x, y) (where x and y are column names) or "complete.cases(x, y)". To filter with multiple conditions use "&", e.g. "x == 1 & y == 2"
Arguments
- df
A data.frame or tibble
- ex
character(1) An character expression for filtering df using dplyr::filter, e.g. 'grepl("X", colname)'
- f
A function to apply to the rows where ex is TRUE and returns a data.frame
- verbose
Should a warning be issued if extra rows are added after applying f? (Default: TRUE)
- ...
Extra arguments for f