
Transform measure names into attribute values
Source:R/flat_table_transform.R
transform_to_values.RdTransforms the measure names into values of a new attribute. The values of the measures will become values of the new measure that is indicated.
Usage
transform_to_values(ft, attribute, measure, id_reverse, na_rm)
# S3 method for class 'flat_table'
transform_to_values(
ft,
attribute = NULL,
measure = NULL,
id_reverse = NULL,
na_rm = TRUE
)Arguments
- ft
A
flat_tableobject.- attribute
A string, new attribute that will store the measures names.
- measure
A string, new measure that will store the measure value.
- id_reverse
A string, name of a new attribute that will store the row id.
- na_rm
A boolean, remove rows from output where the value column is NA.
Details
If we wanted to perform the reverse operation later using the transform_from_values
function, we would need to uniquely identify each original row. By indicating
a value in the id_reverse parameter, an identifier is added that will allow
us to always carry out the inverse operation.
See also
Other flat table transformation functions:
add_custom_column(),
remove_instances_without_measures(),
replace_empty_values(),
replace_string(),
replace_unknown_values(),
select_attributes(),
select_instances(),
select_instances_by_comparison(),
select_measures(),
separate_measures(),
transform_attribute_format(),
transform_from_values(),
transform_to_attribute(),
transform_to_measure()
Examples
ft <- flat_table('iris', iris) |>
transform_to_values(attribute = 'Characteristic',
measure = 'Value')
ft <- flat_table('iris', iris) |>
transform_to_values(attribute = 'Characteristic',
measure = 'Value',
id_reverse = 'id')