set_measure_names.flat_table {rolap}R Documentation

Rename measures

Description

Rename measures in a flat table or in facts in a star database.

Usage

## S3 method for class 'flat_table'
set_measure_names(db, name = NULL, old = NULL, new)

set_measure_names(db, name, old, new)

## S3 method for class 'star_database'
set_measure_names(db, name = NULL, old = NULL, new)

Arguments

db

A flat_table or star_database object.

name

A string, fact name.

old

A vector of names.

new

A vector of names.

Details

To rename the measures there are three possibilities: 1) give only one vector with the new names for all the measures; 2) a vector of old names and another of new names that must correspond; 3) a vector of new names whose names are the old names they replace.

Value

A flat_table or star_database object.

See Also

star_database, flat_table

Other star database and flat table functions: get_attribute_names.flat_table(), get_measure_names.flat_table(), get_similar_attribute_values.flat_table(), get_similar_attribute_values_individually.flat_table(), get_unique_attribute_values.flat_table(), replace_attribute_values.flat_table(), set_attribute_names.flat_table(), snake_case.flat_table()

Examples


db <- star_database(mrs_cause_schema, ft_num) |>
  set_measure_names(
    new = c(
      "Pneumonia and Influenza",
      "All",
      "Rows Aggregated"
    )
  )

ft <- flat_table('iris', iris) |>
  set_measure_names(
    old = c('Petal.Length', 'Petal.Width', 'Sepal.Length', 'Sepal.Width'),
    new = c('pl', 'pw', 'ls', 'sw'))

new <- c('pl', 'pw', 'ls', 'sw')
names(new) <- c('Petal.Length', 'Petal.Width', 'Sepal.Length', 'Sepal.Width')
ft <- flat_table('iris', iris) |>
  set_measure_names(
    new = new)


[Package rolap version 2.5.1 Index]