statar (version 0.4.0)

keep_if: Create new data.table by keeping only certain rows(equivalent to dplyr::filter)

Description

Create new data.table by keeping only certain rows(equivalent to dplyr::filter)

Usage

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

keep_if_(x, .dots, by = NULL)

Arguments

x
a data.table
...
Conditions
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)
)
keep_if(DT, v1 == 1)
keep_if(DT, v1 == min(v1), by = id)

Run the code above in your browser using DataLab