as.level {data.cube}R Documentation

Create level

Description

Create level

Usage

as.level(x, ...)

## Default S3 method:
as.level(x, id.vars = key(x), properties, ...)

## S3 method for class 'data.table'
as.level(x, id.vars = key(x), properties, ...)

Arguments

x

data.table or object with a as.data.table method, build level based on that dataset.

id.vars

character scalar of level primary key.

properties

character vector of column names from dataset to include on that level.

...

arguments passed to methods.

Details

You generally won't need to use that function directly, but use as.dimension that based on hierarchies will produce all levels.

Value

level class object.

See Also

level, hierarchy, dimension, data.cube

Examples

library(data.table)
time.dt = data.table(d = seq(as.Date("2015-01-01"), as.Date("2015-12-31"), by=1)
                     )[, c("m","y") := list(month(d), year(d))
                       ][]
date.level = as.level(time.dt, id.vars="d", properties=c("m","y"))
str(date.level)

[Package data.cube version 0.4.0 Index]