statar (version 0.4.0)

discard_if: Create new data.table after discarding certain rows

Description

Create new data.table after discarding certain rows

Usage

discard_if(x, ..., by = NULL)

discard_if_(x, .dots, by = NULL)

Arguments

x
a data.table
...
Conditions. Rows where the condition evaluates to NA are not discardd. Therefore, discard_if(dt, condition) is not the same as keep_if(x, !condition) with
by
groups in which the condition should be evaluated
.dots
Used to work around non-standard evaluation.

Examples

Run this code
library(data.table)
DT <- data.table(
  id = c(1,2,1),
  v1 = c(1,NA,2)
)
discard_if(DT, v1 == 1)
discard_if(DT, v1 == 1, v1 == 2)
discard_if(DT, v1 == min(v1), by = id)

Run the code above in your browser using DataCamp Workspace