Pipeable data.table call.

Has experimental support for tidy evaluation.

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

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))
#> # A tidytable: 3 × 4
#>       x     y z     double_x
#>   <int> <int> <chr>    <dbl>
#> 1     3     6 b            6
#> 2     2     5 a            4
#> 3     1     4 a            2

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

df %>%
  add_one(x)
#> # A tidytable: 3 × 3
#>       x     y z    
#>   <dbl> <int> <chr>
#> 1     2     4 a    
#> 2     3     5 a    
#> 3     4     6 b