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 |
A data frame with the grouped columns.
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
.
#> V2 X2 X3 #> 1 11 26 51 #> 2 12 27 52 #> 3 13 28 53 #> 4 14 29 54 #> 5 15 30 55 #> 6 16 31 56 #> 7 17 32 57 #> 8 18 33 58 #> 9 19 34 59 #> 10 20 35 60