Combination of set*
functions provided by data.table.
This is memeroy efficient because no copy is made at all.
set_in_dt(.data, ...) set_mutate(.data, ..., by = NULL) set_arrange(.data, ..., cols = NULL, order = 1L) set_rename(.data, ...) set_relocate(.data, ..., how = "first", where = NULL) set_add_count(.data, ..., .name = "n") set_replace_na(.data, ..., to) set_fill_na(.data, ..., direction = "down")
.data | A data.table |
---|---|
... | For |
by | Mutate by which group(s)? |
cols | For |
order | For |
how | For |
where | For |
.name | For |
to | What value should NA replace by? |
direction | Direction in which to fill missing values. Currently either "down" (the default) or "up". |
The input is modified by reference, and returned (invisibly) so it can be used in compound statements.
These are a set of functions for modification on data.table by reference. They follow the same syntax of similar tidyfst functions. They do not return the result and considered to be memory efficient.
library(pryr)#>#> #>rm(list = ls()) nr_of_rows <- 1e5 df <- data.table( Logical = sample(c(TRUE, FALSE, NA), prob = c(0.85, 0.1, 0.05), nr_of_rows, replace = TRUE) ) mem_change(mutate_dt(df,one = 1) -> res)#> 1.22 MB#> 821 kB#> [1] TRUE