Hi,
I have a bag dataset with around 600 variables. I need to replace the variables with the new names given in a list. The example has been posted below. Here the variables in the dataframe "data" have to be changed as given the column 'new variable' in the 'list'. How can I achieve this?
library(tidyverse)
library(janitor)
tibble::tribble(
list<- ~old_variable, ~new_variable,
"l2c1_id_pic1", "l1c1_id_pic1",
"l2c1_id_pic2", "l1c1_id_pic2",
"l2c2_id_col1", "l1c2_id_col1",
"l2c2_id_col2", "l1c2_id_col2",
"l3el1_desc", "l1c1_desc"
)
data<-tibble::tribble(
~student_id, ~l1c1_id_pic1, ~l1c1_id_pic2, ~l2c1_id_col1, ~l2c1_id_col2, ~l3el1_desc,
"XXC", 1L, 1L, 1L, 1L, 1L,
"GGH", 1L, 1L, 0L, 0L, 1L,
"SHS", 1L, 0L, 1L, 0L, 1L,
"DDK", 1L, 1L, 0L, 0L, 1L,
"DJS", 0L, 1L, 0L, 0L, 1L
)