add_custom_column {rolap}R Documentation

Add custom column

Description

Add a column returned by a function that takes the data of the flat table as a parameter.

Usage

add_custom_column(ft, name, definition)

## S3 method for class 'flat_table'
add_custom_column(ft, name = NULL, definition)

Arguments

ft

A flat_table object.

name

A string, new column name.

definition

A function that returns a table column.

Value

A flat_table object.

See Also

flat_table

Other flat table transformation functions: remove_instances_without_measures(), replace_empty_values(), replace_string(), replace_unknown_values(), select_attributes(), select_instances_by_comparison(), select_instances(), select_measures(), separate_measures(), transform_attribute_format(), transform_from_values(), transform_to_attribute(), transform_to_measure(), transform_to_values()

Examples


f <- function(table) {
  paste0(table$City, ' - ', table$State)
}

ft <- flat_table('ft_num', ft_num) |>
  add_custom_column(name = 'city_state', definition = f)


[Package rolap version 2.5.1 Index]