Description Usage Arguments Value See Also Examples
Build dimension
1 2 3 4 5 6 7 8 | as.dimension(x, ...)
## Default S3 method:
as.dimension(x, id.vars, hierarchies = NULL, ...)
## S3 method for class 'data.table'
as.dimension(x, id.vars = key(x), hierarchies = NULL,
...)
|
x |
data.table or object with a as.data.table method, build dimension based on that dataset. |
id.vars |
character scalar of dimension primary key. |
hierarchies |
list of hierarchies of levels and their attributes. |
... |
arguments passed to methods. |
dimension class object.
dimension
, hierarchy
, level
, data.cube
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | library(data.table)
time.dt = data.table(date = seq(as.Date("2015-01-01"), as.Date("2015-12-31"), by=1)
)[, c("month","quarter","year") := list(month(date), year(date), quarter(date))
][, c("weekday","week") := list(weekdays(date), week(date))][]
hierarchies = list(
"monthly" = list(
"year" = character(),
"quarter" = character(),
"month" = character(),
"date" = c("year","month")
),
"weekly" = list(
"year" = character(),
"week" = character(),
"weekday" = character(),
"date" = c("year","week","weekday")
)
)
time = as.dimension(
x = time.dt,
id.vars = "date",
hierarchies = hierarchies
)
str(time)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.