aggregateCol | R Documentation |
aggregateCol()
performs summary statistics on a specific subset of columns.
aggregateCol(data, grp, names_aggreg = NULL, FUN = sum, ...)
data |
a data frame. |
grp |
an integer vector, one value per |
names_aggreg |
column names for aggregated columns. |
FUN |
a function to be applied to all groups of columns. |
... |
further arguments to be passed to |
grp
is an integer vector, whose length is the number of columns of the
input data frame, is used to assign a group to each column that explicit the
sub-setting. Furthermore columns can be either kept as is using 0
or
discarded using NA
.
A data frame with the grouped columns.
stats::aggregate()
base::split
mat1 <- matrix(1:70,10) grp1 <- c(NA,0, 1, 1, 2, 2, 2) aggregateCol(mat1, grp1, FUN = mean)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.