Skip to contents

This function renames columns in a given dataframe based on a mapping table. The mapping table should contain the old column names and the new column names that they should be mapped to.

Usage

map_column_names(data, mapping, study = "emi")

Arguments

data

The dataframe whose columns are to be renamed.

mapping

A dataframe containing at least two columns: `embrace_i_column` for the Embrace I dataset column names, and `embrace_ii_column` for the Embrace II dataset column names.

study

name of study

Value

A dataframe with columns renamed based on the mapping table.

Examples

if (FALSE) { # \dontrun{
  mapping <- data.frame(embrace_i_column = c('col1', 'col2'),
                        embrace_ii_column = c('column1', 'column2'),
                        new_combined_name = c('new_col1', 'new_col2'))
  data <- data.frame(col1 = 1:5, col2 = 6:10)
  new_data <- map_columns_based_on_mapping(data, mapping)
} # }