groupwiseSum.RdCalculates sums for groups.
groupwiseSum(
formula = NULL,
data = NULL,
var = NULL,
group = NULL,
digits = NULL,
...
)A formula indicating the measurement variable and the grouping variables. e.g. y ~ x1 + x2.
The data frame to use.
The measurement variable to use. The name is in double quotes.
The grouping variable to use. The name is in double quotes. Multiple names are listed as a vector. (See example.)
The number of significant figures to use in output.
The default is NULL, which results in no
rounding of values.
Other arguments passed to the sum function
A data frame of statistics by group.
The input should include either formula and data;
or data, var, and group. (See examples).
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.
### Example with formula notation
data(AndersonBias)
groupwiseSum(Count ~ Result + Gender,
data = AndersonBias)
#> Result Gender n Sum
#> 1 Pass Female 4 44
#> 2 Pass Male 4 49
#> 3 Fail Female 4 24
#> 4 Fail Male 4 64
### Example with variable notation
data(AndersonBias)
groupwiseSum(data = AndersonBias,
var = "Count",
group = c("Result", "Gender"))
#> Result Gender n Sum
#> 1 Pass Female 4 44
#> 2 Pass Male 4 49
#> 3 Fail Female 4 24
#> 4 Fail Male 4 64