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 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 data.table
filter_sd(.data, ..., .expr = FALSE)
An instance of ExprBuilder.
See data.table::data.table and the details here.
The filtering function or predicate.
Possibly more arguments for .how
.
Passed to data.table::data.table.
See where-table.express.
Logical. Whether to apply rlang::parse_expr()
to obtain the expressions.
Logical. Should a new frame be automatically chained to the expression if the clause being set already exists?
Internal. Passed to rlang::caller_env()
to find the function specified in
.how
and standardize its call.
If the input is a data.table
and .expr
is TRUE
, an instance of
EagerExprBuilder will be returned. Useful if you want to add clauses to j
, e.g. with
mutate-table.express.
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:
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.table
s.
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)
Run the code above in your browser using DataLab