define_dimension {starschemar} | R Documentation |
Define dimensions in a dimensional_model
object
Description
To define a dimension in a dimensional_model
object, we have to define its
name and the set of attributes that make it up.
Usage
define_dimension(st, name = NULL, attributes = NULL)
## S3 method for class 'dimensional_model'
define_dimension(st, name = NULL, attributes = NULL)
Arguments
st |
A |
name |
A string, name of the dimension. |
attributes |
A vector of attribute names. |
Details
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.
Value
A dimensional_model
object.
See Also
Other star definition functions:
define_fact()
,
dimensional_model()
Examples
# 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"))
[Package starschemar version 1.2.5 Index]