View source: R/VERBS-filter_sd.R
| filter_sd | R Documentation |
Helper to filter rows with the same condition applied to a subset of the data.
filter_sd(.data, .SDcols, .how = Negate(is.na), ...)
## S3 method for class 'ExprBuilder'
filter_sd(
.data,
.SDcols,
.how = Negate(is.na),
...,
which,
.collapse = `&`,
.parse = getOption("table.express.parse", FALSE),
.chain = getOption("table.express.chain", TRUE),
.caller_env_n = 1L
)
## S3 method for class 'data.table'
filter_sd(.data, ..., .expr = FALSE)
.data |
An instance of ExprBuilder. |
.SDcols |
See data.table::data.table and the details here. |
.how |
The filtering function or predicate. |
... |
Possibly more arguments for |
which |
Passed to data.table::data.table. |
.collapse |
See where-table.express. |
.parse |
Logical. Whether to apply |
.chain |
Logical. Should a new frame be automatically chained to the expression if the clause being set already exists? |
.caller_env_n |
Internal. Passed to |
.expr |
If the input is a |
This function adds/chains an i expression that will be evaluated by data.table::data.table,
and it supports the .COL pronoun and lambdas as formulas. The .how condition is applied to
all .SDcols.
Additionally, .SDcols supports:
tidyselect::select_helpers
A predicate using the .COL pronoun that should return a single logical when .COL is
replaced by a column of the data.
A formula using . or .x instead of the aforementioned .COL.
The caveat is that the expression is evaluated eagerly, i.e. with the currently captured
data.table. Consider using chain() to explicitly capture intermediate results as actual
data.tables.
To see more examples, check the vignette, or the table.express-package entry.
data("mtcars")
data.table::as.data.table(mtcars) %>%
filter_sd(c("vs", "am"), ~ .x == 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.