set_attribute_names.flat_table {rolap}R Documentation

Rename attributes

Description

Rename attributes in a flat table or a dimension in a star database.

Usage

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

set_attribute_names(db, name, old, new)

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

Arguments

db

A flat_table or star_database object.

name

A string, dimension name.

old

A vector of names.

new

A vector of names.

Details

To rename the attributes there are three possibilities: 1) give only one vector with the new names for all the attributes; 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_measure_names.flat_table(), snake_case.flat_table()

Examples


db <- star_database(mrs_cause_schema, ft_num) |>
  set_attribute_names(
    name = "where",
    new = c(
      "Region",
      "State",
      "City"
    )
  )

db <- star_database(mrs_cause_schema, ft_num) |>
  set_attribute_names(name = "where",
                      old = "REGION",
                      new = "Region")

new <- "Region"
names(new) <- "REGION"
db <- star_database(mrs_cause_schema, ft_num) |>
  set_attribute_names(name = "where",
                      new = new)

ft <- flat_table('iris', iris) |>
  set_attribute_names(
    old = 'Species',
    new = 'species')

new <- "species"
names(new) <- "Species"
ft <- flat_table('iris', iris) |>
  set_attribute_names(
    new = new)


[Package rolap version 2.5.1 Index]