as.level: Create level

Description Usage Arguments Details Value See Also Examples

View source: R/as.level.R

Description

Create level

Usage

1
2
3
4
5
6
7
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

1
2
3
4
5
6
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)

jangorecki/data.cube documentation built on Aug. 22, 2019, 4:15 p.m.