as.level {data.cube} | R Documentation |
Create level
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, ...)
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. |
You generally won't need to use that function directly, but use as.dimension
that based on hierarchies will produce all levels.
level class object.
level
, hierarchy
, dimension
, data.cube
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)