Learn R Programming

caroline (version 0.3-6)

regroupDF: Regroup a dataframe by a new trumping factor (NA's allowed).

Description

Used to group a dataframe of numbers by a factor that need not be the same length.

Usage

regroupDF(df, old, new, cols, funcs=rep('sum',length(cols)), combine=TRUE)

Arguments

df
a dataframe.
old
the ids to match the rows in df to the 'new' grouping ids.
new
the new ids (must be a vector of the same length as 'old'.
cols
the colums to include in the output.
funcs
the functions to perform on the output (default is to sum) .
combine
Determines wether to combine with existing groupings or to start fresh.