define_facts {rolap}R Documentation

Define facts in a star_schema object.

Description

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).

Usage

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
)

Arguments

schema

A star_schema object.

facts

A fact_schema object.

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.

Details

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.

Value

A star_schema object.

See Also

star_database

Other star schema definition functions: define_dimension(), dimension_schema(), fact_schema(), star_schema()

Examples


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)

[Package rolap version 2.5.1 Index]