Skip to contents

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

Usage

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

set_measure_names(db, name, old, new)

# S3 method for 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.

Value

A flat_table or star_database object.

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.

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)