sumBy: Sum variables in a dataframe by a set of factor levels

View source: R/sumBy.R

sumByR Documentation

Sum variables in a dataframe by a set of factor levels

Description

Sums variables in a dataframe by a set of factor levels. Uses getFactorLevels to identify the unique factor combinations in columns identified as factors.

Usage

sumBy(df, factors, vars, sortBy = NULL, ascending = TRUE)

Arguments

df
  • dataframe (or object that can be coerced to a dataframe) with variables to be summed and factor levels to be summed by

factors
  • vector of names of columns in df to serve as factors in the summations

vars
  • vector of names of column in df that should be summed

sortBy
  • vector of factor column names to sort results by

ascending
  • sort in ascending order

Details

None.

Value

a dataframe of results with columns corresponding to factors and vars


wStockhausen/wtsUtilities documentation built on March 16, 2024, 10:38 a.m.