dt: Pipeable data.table call

View source: R/dt.R

dtR Documentation

Pipeable data.table call

Description

Pipeable data.table call.

Has experimental support for tidy evaluation.

Note: This function does not use data.table's modify-by-reference

Usage

dt(.df, ...)

Arguments

.df

A data.frame or data.table

...

Arguments passed to data.table call. See ?data.table::⁠[.data.table⁠

Examples

df <- tidytable(
  x = 1:3,
  y = 4:6,
  z = c("a", "a", "b")
)

df %>%
  dt(, double_x := x * 2) %>%
  dt(order(-double_x))

# Experimental support for tidy evaluation
add_one <- function(data, col) {
  data %>%
    dt(, new_col := {{ col }} + 1)
}

df %>%
  add_one(x)

tidytable documentation built on Oct. 5, 2023, 5:07 p.m.