groupwiseSum {rcompanion} | R Documentation |
Groupwise sums
Description
Calculates sums for groups.
Usage
groupwiseSum(
formula = NULL,
data = NULL,
var = NULL,
group = NULL,
digits = NULL,
...
)
Arguments
formula |
A formula indicating the measurement variable and the grouping variables. e.g. y ~ x1 + x2. |
data |
The data frame to use. |
var |
The measurement variable to use. The name is in double quotes. |
group |
The grouping variable to use. The name is in double quotes. Multiple names are listed as a vector. (See example.) |
digits |
The number of significant figures to use in output.
The default is |
... |
Other arguments passed to the |
Details
The input should include either formula
and data
;
or data
, var
, and group
. (See examples).
Value
A data frame of statistics by group.
Note
The parsing of the formula is simplistic. The first variable on the left side is used as the measurement variable. The variables on the right side are used for the grouping variables.
Beginning in version 2.0, there is no rounding of results by default. Rounding results can cause confusion if the user is expecting exact sums.
Author(s)
Salvatore Mangiafico, mangiafico@njaes.rutgers.edu
See Also
groupwiseMean
,
groupwiseMedian
,
groupwiseHuber
,
groupwiseGeometric
Examples
### Example with formula notation
data(AndersonBias)
groupwiseSum(Count ~ Result + Gender,
data = AndersonBias)
### Example with variable notation
data(AndersonBias)
groupwiseSum(data = AndersonBias,
var = "Count",
group = c("Result", "Gender"))