Apply a Function to a Data Frame Split by Factors
By(x, INDICES, FUN, COLUMNS, array = FALSE, ...)
x
: Data frameINDICES
: Indices (vector or list of indices, vector of column names, or formula of column names)FUN
: A function to be applied to data frame subsets of 'data'.COLUMNS
: (Optional) subset of columns of x to work onarray
: if TRUE an array/matrix is always returned...
: Additional arguments to lower-level functionsSimple wrapper of the 'by' function
By(datasets::CO2,~Treatment+Type,colMeans,~conc) By(datasets::CO2,~Treatment+Type,colMeans,~conc+uptake)
Klaus K. Holst