groupr: Create groupr object.

Description Usage Arguments Value Examples

Description

Constructor function for groupr object. This function takes a data frame as input and returns a grouping object as output. The groupr is essentially a list of lists of data frames, one data frame for every possible combination of groups. For example, if there are two groups, A and B, four data frames are returned: data frames for A, B, both A and B, and a data frame summarizing the whole dataset.

Usage

1
groupr(df, groups, functions = list(count = "n()"), depth = length(groups))

Arguments

df

A data frame of raw data.

groups

A character vector of column names in df that will be basis for aggregation.

functions

A named list of functions for aggregation.

depth

How far down the tree the combinations should work out.

Value

A grouping object (list that aggregates functions by every potential combination)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
default_data <- data.frame(
  my_group1 = rep(c("A", "B"), each = 4),
  my_group2 = rep(c("foo", "bar", "baz", "potato"), each=2),
  my_data = runif(n = 8)
)
groupr_object <- groupr(
  df = default_data,
  groups = "my_group1",
  functions = list(rando_sum = "sum(my_data)")
)
print(groupr_object)

athompson1991/groupR documentation built on May 10, 2019, 2:09 p.m.