Skip to contents

Transforms 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 flat_table
transform_to_values(
  ft,
  attribute = NULL,
  measure = NULL,
  id_reverse = NULL,
  na_rm = TRUE
)

Arguments

ft

A flat_table object.

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.

Value

A flat_table object.

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.

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')