lapply_dt | R Documentation |
Convenience function to apply a function to columns of a data.table/frame. The syntax for the columns is flexible
lapply_dt(
x,
dt,
LFUN = "identity",
natype = NA,
as.data.table = T,
evalcall = FALSE
)
x |
fields to apply function to |
dt |
data.table/frame |
LFUN |
either a character name of a function, or a function |
natype |
the type of NA which is to be specified as one of NA, NA_character_, NA_real_, or NA_integer_ |
as.data.table |
a logical indicating whether to coerce the output to a data.table |
evalcall |
logical flag to evaluate x as a call or not |
lapply_dt(c(newcolname = colname), dt, dosomething) will give a data.table or list with the column name renamed to newcolname lapply_dt(.(newcolname = colname)...) also works as well. Note that no quotations are needed.
data.table/frame if as.data.table is TRUE, otherwise a list
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.