Learn R Programming

rcompanion (version 2.4.36)

groupwiseSum: Groupwise sums

Description

Calculates sums for groups.

Usage

groupwiseSum(
  formula = NULL,
  data = NULL,
  var = NULL,
  group = NULL,
  digits = NULL,
  ...
)

Value

A data frame of statistics by group.

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

Author

Salvatore Mangiafico, mangiafico@njaes.rutgers.edu

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
### 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"))
                      

Run the code above in your browser using DataLab