role_playing_dimension | R Documentation |
The same dimension can play several roles in relation to the facts. We can define the main dimension and the dimensions that play different roles.
role_playing_dimension(db, rpd, roles, rpd_att_names, att_names)
## S3 method for class 'star_database'
role_playing_dimension(db, rpd, roles, rpd_att_names = FALSE, att_names = NULL)
db |
A |
rpd |
A string, dimension name (role playing dimension). |
roles |
A vector of strings, dimension names (dimension roles). |
rpd_att_names |
A boolean, common attribute names taken from rpd dimension. |
att_names |
A vector of strings, common attribute names. |
As a result, all the dimensions will have the same instances and, if we deem it necessary, also the same name of their attributes (except the surrogate key).
A star_database
object.
star_schema
, flat_table
Other star database definition functions:
get_dimension_names()
,
get_dimension_table()
,
get_fact_names()
,
get_role_playing_dimension_names()
,
get_table_names()
,
group_dimension_instances()
,
star_database()
s <- star_schema() |>
define_facts(fact_schema(
name = "mrs_cause",
measures = c(
"Pneumonia and Influenza Deaths",
"All Deaths"
)
)) |>
define_dimension(dimension_schema(
name = "When",
attributes = c(
"Year",
"WEEK",
"Week Ending Date"
)
)) |>
define_dimension(dimension_schema(
name = "When Available",
attributes = c(
"Data Availability Year",
"Data Availability Week",
"Data Availability Date"
)
)) |>
define_dimension(dimension_schema(
name = "When Received",
attributes = c(
"Reception Year",
"Reception Week",
"Reception Date"
)
)) |>
define_dimension(dimension_schema(
name = "where",
attributes = c(
"REGION",
"State",
"City"
)
))
db <- star_database(s, ft_cause_rpd) |>
role_playing_dimension(
rpd = "When",
roles = c("When Available", "When Received"),
rpd_att_names = TRUE
)
db <- star_database(s, ft_cause_rpd) |>
role_playing_dimension("When",
c("When Available", "When Received"),
att_names = c("Year", "Week", "Date"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.