Learn R Programming

hypercube (version 0.2.1)

generateCube: Generates a hypercube from a given dataframe

Description

This function generates a hypercube from a given dataframe. The dimensions of the hypercube correspond to a set of selected columns from the dataframe.

Usage

generateCube(
  data,
  columns,
  valueColumn,
  fun = c("sum", "min", "max", "prod", "mean", "median", "sd", "count")
)

Arguments

data

A dataframe that is used as source for the hypercube.

columns

A vector of column names that will form the dimensions of the hypercube.

valueColumn

The name of the column that provides the values for the cells of the hypercube.

fun

Aggregation function for aggregating over those columns that do not correspond with any dimension of the hypercube.

Value

Returns a Cube object.

See Also

Cube

Examples

Run this code
# NOT RUN {
data("sales")
cube = generateCube(sales, columns = list(time = c("month", "year"),
      location = c("state"), product = "product"), valueColumn = "amount")

# }

Run the code above in your browser using DataLab