View source: R/dimensional_model_define_dimension.R
define_dimension | R Documentation |
dimensional_model
objectTo define a dimension in a dimensional_model
object, we have to define its
name and the set of attributes that make it up.
define_dimension(st, name = NULL, attributes = NULL)
## S3 method for class 'dimensional_model'
define_dimension(st, name = NULL, attributes = NULL)
st |
A |
name |
A string, name of the dimension. |
attributes |
A vector of attribute names. |
To get a star schema (a star_schema
object) we need a flat table
(implemented through a tibble
) and a dimensional_model
object. The
definition of dimensions in the dimensional_model
object is made from the
flat table column names. Using the dput
function we can list the column
names of the flat table so that we do not have to type their names.
A dimensional_model
object.
Other star definition functions:
define_fact()
,
dimensional_model()
# dput(colnames(mrs_age))
#
# c(
# "Reception Year",
# "Reception Week",
# "Reception Date",
# "Data Availability Year",
# "Data Availability Week",
# "Data Availability Date",
# "Year",
# "WEEK",
# "Week Ending Date",
# "REGION",
# "State",
# "City",
# "Age Range",
# "Deaths"
# )
dm <- dimensional_model() |>
define_dimension(name = "When",
attributes = c("Week Ending Date",
"WEEK",
"Year")) |>
define_dimension(name = "When Available",
attributes = c("Data Availability Date",
"Data Availability Week",
"Data Availability Year")) |>
define_dimension(name = "Where",
attributes = c("REGION",
"State",
"City")) |>
define_dimension(name = "Who",
attributes = c("Age Range"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.