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 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.
See also
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)