Learn R Programming

rolap (version 2.5.1)

lookup_table: Transform a flat table into a look up table

Description

Checks that the given attributes form a primary key of the table. Otherwise, group the records so that they form a primary key. To carry out the groupings, aggregation functions for attributes and measures must be provided.

Usage

lookup_table(
  ft,
  pk_attributes,
  attributes,
  attribute_agg,
  measures,
  measure_agg
)

# S3 method for flat_table lookup_table( ft, pk_attributes = NULL, attributes = NULL, attribute_agg = NULL, measures = NULL, measure_agg = NULL )

Value

A flat_table object.

Arguments

ft

A flat_table object.

pk_attributes

A vector of strings, attribute names.

attributes

A vector of strings, rest of attribute names.

attribute_agg

A vector of strings, attribute aggregation functions.

measures

A vector of strings, measure names.

measure_agg

A vector of strings, measure aggregation functions.

Details

If the table does not have measures, attributes with equal values are grouped without the need to indicate a grouping function.

If no attribute is indicated, all the attributes are considered to form the primary key.

See Also

flat_table

Other flat table join functions: check_lookup_table(), get_pk_attribute_names(), join_lookup_table()

Examples

Run this code

ft <- flat_table('iris', iris) |>
  lookup_table(
    measures = c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"),
    measure_agg = c('MAX', 'MIN', 'SUM', 'MEAN')
  )

Run the code above in your browser using DataLab