define_facts | R Documentation |
star_schema
object.Facts are part of a star_schema
object. They can be defined directly
as a fact_schema
object or giving the name and a set of measures
that can be empty (does not have explicit measures).
define_facts(schema, facts, name, measures, agg_functions, nrow_agg)
## S3 method for class 'star_schema'
define_facts(
schema,
facts = NULL,
name = NULL,
measures = NULL,
agg_functions = NULL,
nrow_agg = NULL
)
schema |
A |
facts |
A |
name |
A string, name of the fact. |
measures |
A vector of measure names. |
agg_functions |
A vector of aggregation function names, each one for its corresponding measure. If none is indicated, the default is SUM. Additionally they can be MAX or MIN. |
nrow_agg |
A string, name of a new measure that represents the COUNT of rows aggregated for each resulting row. |
Associated with each measurement there is an aggregation function that can be SUM, MAX or MIN. AVG is not considered among the possible aggregation functions: The reason is that calculating AVG by considering subsets of data does not necessarily yield the AVG of the total data.
An additional measurement corresponding to the COUNT of aggregated rows is added which, together with SUM, allows us to obtain the mean if needed.
A star_schema
object.
star_database
Other star schema definition functions:
define_dimension()
,
dimension_schema()
,
fact_schema()
,
star_schema()
s <- star_schema() |>
define_facts(
name = "mrs_cause",
measures = c(
"Pneumonia and Influenza Deaths",
"Other Deaths"
)
)
s <- star_schema()
f <- fact_schema(
name = "mrs_cause",
measures = c(
"Pneumonia and Influenza Deaths",
"Other Deaths"
)
)
s <- s |>
define_facts(f)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.