rcompanion (version 2.2.2)

groupwiseSum: 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 NULL, which results in no rounding of values.

...

Other arguments passed to the sum function

Value

A data frame of statistics by group.

Details

The input should include either formula and data; or data, var, and group. (See examples).

See Also

groupwiseMean, groupwiseMedian, groupwiseHuber, groupwiseGeometric

Examples

Run this code
# NOT RUN {
### Example with formula notation
data(AndersonBias)
groupwiseSum(Count ~ Result + Sex,
             data        = AndersonBias)
                
### Example with variable notation
data(AndersonBias)
groupwiseSum(data        = AndersonBias,
             var         = "Count",
             group       = c("Result", "Sex"))
                      
# }

Run the code above in your browser using DataCamp Workspace