Skip to contents

This function renames variables in a long-format metadata data frame based on their hierarchical groupings. Spanning variables are renamed using the name of their hierarchy in uppercase, while response variables linked by an equation (specified in the hrc_indicator column) are grouped together, and a new grouping variable is created.

Usage

identify_hrc(df_metadata_long)

Arguments

df_metadata_long

A data frame in long format with the following required columns:

  • table_name: Identifies the table.

  • field : name of the field of the table.

  • indicator: name of the indicator of the table.

  • hrc_indicator: Specifies linked response variables.

  • spanning_*, hrc_spanning_*: Spanning variables and their hierarchies.

Value

list_hrc_identified, a list with two elements:

  • df_indicators: The updated data frame with renamed variables and grouped response variables.

  • df_variable_info: A data frame mapping original variable names (spanning_old) to their renamed counterparts (spanning).

Examples

if (FALSE) { # \dontrun{
data(metadata_pizza_lettuce)

metadata_pizza_lettuce_long <- wide_to_long(metadata_pizza_lettuce)

list_hrc_identified <- identify_hrc(metadata_pizza_lettuce_long)

str(list_hrc_identified)
} # }