create_hypercube: Create a data hypercube

View source: R/create.R

create_hypercubeR Documentation

Create a data hypercube

Description

create_hypercube creates a data cube from a flat data table. This is very similar to groupingsets() in the data.table package.

Usage

create_hypercube(
  data,
  columns,
  drop_sum_columns = "",
  use_na = "ifany",
  drop_na_levels = TRUE,
  label_for_sum = NULL
)

Arguments

data

Data object.

columns

Character vector, must be more than 1 column provided.

drop_sum_columns

Character vector of which columns to drop the 'sum' levels.

use_na

Character vector regarding if NA levels should be included in tallies, passed to table.

drop_na_levels

Logical vector, if TRUE all NA factor levels are dropped.

label_for_sum

Character vector, a label to replace the default text of 'sum' for column totals.

Details

If drop_na_levels is set to TRUE all factor levels which are NA will be removed. A label can also be set for all the 'sum' levels; typically these 'sum' levels are NA_character_ but they will not be removed by drop_na_levels (only NA levels that exist in the data prior to the summarizing are dropped.

Value

A data.frame or tibble is returned

Examples

create_hypercube(mtcars, columns = c('gear', 'cyl'), drop_sum_columns = 'cyl')


al-obrien/farrago documentation built on April 14, 2023, 6:20 p.m.