Learn R Programming

rolap (version 2.5.1)

run_query: Run query

Description

Once we have selected the facts, dimensions and defined the conditions on the instances, we can execute the query to obtain the result.

Usage

run_query(db, sq)

# S3 method for star_database run_query(db, sq)

Value

A star_database object.

Arguments

db

A star_database object.

sq

A star_query object.

Details

As an option, we can indicate if we do not want to unify the facts in the case of having the same grain.

See Also

Other query functions: as_GeoPackage(), as_geolayer(), filter_dimension(), get_layer(), get_variable_description(), get_variables(), select_dimension(), select_fact(), set_layer(), set_variables(), star_query()

Examples

Run this code

sq <- mrs_db |>
  star_query() |>
  select_dimension(name = "where",
                   attributes = c("city", "state")) |>
  select_dimension(name = "when",
                   attributes = "year") |>
  select_fact(
    name = "mrs_age",
    measures = "all_deaths",
    agg_functions = "MAX"
  ) |>
  select_fact(
    name = "mrs_cause",
    measures = c("pneumonia_and_influenza_deaths", "all_deaths")
  ) |>
  filter_dimension(name = "when", week <= " 3") |>
  filter_dimension(name = "where", city == "Bridgeport")

mrs_db_2 <- mrs_db |>
  run_query(sq)

Run the code above in your browser using DataLab