Learn R Programming

table.express (version 0.1.1)

filter_sd: Filter subset of data

Description

Helper to filter rows with the same condition applied to a subset of the data.

Usage

filter_sd(.data, .how = Negate(is.na), ..., .SDcols, .collapse = `&`,
  .parse = getOption("table.express.parse", FALSE),
  .chain = getOption("table.express.chain", TRUE))

Arguments

.data

An instance of ExprBuilder.

.how

The function or function call that will perform the transformation.

...

Possibly more arguments for .how.

.SDcols

See data.table::data.table and the details here.

.collapse
.parse

Logical. Whether to apply rlang::parse_expr() to obtain the expressions.

.chain

Logical. Should a new frame be automatically chained to the expression if the clause being set already exists?

Details

This function adds/chains a where expression that will be evaluated by data.table::data.table. The .how condition is applied to all specified .SDcols, and it supports the .COL pronoun.

Additionally, .SDcols supports tidyselect::select_helpers, with the caveat 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.

Examples

Run this code
# NOT RUN {
data("mtcars")

data.table::as.data.table(mtcars) %>%
    start_expr %>%
    filter_sd(.COL == 1, .SDcols = c("vs", "am"))

# }

Run the code above in your browser using DataLab