splitMerge | R Documentation |
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"
splitMerge(df, ex, f, verbose = TRUE, ...)
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 |
df where function f has been applied only to the rows where ex is TRUE
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.