aggregate,data.table-method | R Documentation |
data.table
object.Compute a group-by operation over a data.table
in a functional, pipe
compatible format.
## S4 method for signature 'data.table'
aggregate(
x,
by,
...,
subset = TRUE,
nthread = 1,
progress = TRUE,
BPPARAM = NULL,
enlist = TRUE,
moreArgs = list()
)
x |
|
by |
|
... |
|
subset |
|
nthread |
|
progress |
|
BPPARAM |
|
enlist |
|
moreArgs |
|
This S4 method override the default aggregate
method for a data.frame
and as such you need to call aggregate.data.frame
directly to get the
original S3 method for a data.table
.
Arguments in ...
are substituted and wrapped in a list, which is passed
through to the j argument of [.data.table
internally. The function currently
tries to build informative column names for unnamed arguments in ...
by
appending the name of each function call with the name of its first argument,
which is assumed to be the column name being aggregated over. If an argument
to ...
is named, that will be the column name of its value in the resulting
data.table
.
The primary use case for enlist=FALSE
is to allow computation of dependent
aggregations, where the output from a previous aggregation is required in a
subsequent one. For this case, wrap your call in {
and assign intermediate
results to variables, returning the final results as a list where each list
item will become a column in the final table with the corresponding name.
Name inference is disabled for this case, since it is assumed you will name
the returned list items appropriately.
A major advantage over multiple calls to aggregate
is that
the overhead of parallelization is paid only once even for complex multi-step
computations like fitting a model, capturing its paramters, and making
predictions using it. It also allows capturing arbitrarily complex calls
which can be recomputed later using the
update,TreatmentResponseExperiment-method
A potential disadvantage is increased RAM usage per
thread due to storing intermediate values in variables, as well as any
memory allocation overhead associate therewith.
data.table
of aggregated results with an aggregations
attribute
capturing metadata about the last aggregation performed on the table.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.