setj | R Documentation |
These functions manipulate existing columns of your data.table
by reference
based on a selection of columns, a predicate function or a regex pattern that the
column name must match.
setj_at(DT, cols, .f, ...)
setj_if(DT, .p, .f, ...)
setj_grep(DT, pattern, .f, ...)
DT |
( |
cols |
( |
.f |
( |
... |
Additional function arguments you want to supply to |
.p |
( |
pattern |
( |
setj_at()
takes an integer (!) vector of column indices or a character vector of
column names as input for cols
and applies .f
on the corresponding columns.
If you supply indices or column names which don't exist in your data.table
you will get an informative message.
setj_if()
takes a predicate function as input for .p
.
The function .f
will then be applied to those columns for which
.p
returns TRUE
.
If the predicate function returns FALSE
for all columns you will get an
informative message.
setj_grep()
manipulates columns based on regular expression pattern matches.
For that you need to pass a single regex pattern to the pattern
argument.
If the pattern doesn't match any of your data.table
columns you will get
an informative message.
(data.table::data.table()
)
The functions invisibly return the modified data.table
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.