The function applied to the values of each group, as a data frame. Equivalent to R's aggregate().
Formula form, aggregate(formula, data, fun): "y ~ g", "y ~ g + h", "cbind(y, z) ~ g" or ". ~ g" (every
column not on the right). The grouping variables are all the variables of the right-hand side in order of first
appearance, whatever its operators ("y ~ g:h" and "y ~ g * h" group by g and h); "y ~ ." groups by every
column not summarised, and "y ~ 1" gives one row without a grouping column. The rows with a missing value in any
variable of the formula are dropped first. Data frame form, aggregate(x, by, fun): the columns of x summarised
by the label columns of by (its keys name them); only the rows with a missing label are dropped, so fun sees the
missing values of x.
The result has the grouping columns first (with the labels as in the data), then one column per summarised column,
and one row per non-empty combination of the groups (the first factor varying fastest). When fun returns k > 1
values, a summarised column y becomes y.1, ..., y.k (an array) or y.<name> (an object of numbers).
The function applied to the values of each group, as a data frame. Equivalent to R's
aggregate().Formula form,
aggregate(formula, data, fun):"y ~ g","y ~ g + h","cbind(y, z) ~ g"or". ~ g"(every column not on the right). The grouping variables are all the variables of the right-hand side in order of first appearance, whatever its operators ("y ~ g:h"and"y ~ g * h"group by g and h);"y ~ ."groups by every column not summarised, and"y ~ 1"gives one row without a grouping column. The rows with a missing value in any variable of the formula are dropped first. Data frame form,aggregate(x, by, fun): the columns ofxsummarised by the label columns ofby(its keys name them); only the rows with a missing label are dropped, sofunsees the missing values ofx.The result has the grouping columns first (with the labels as in the data), then one column per summarised column, and one row per non-empty combination of the groups (the first factor varying fastest). When
funreturns k > 1 values, a summarised columnybecomesy.1, ...,y.k(an array) ory.<name>(an object of numbers).