I recoded columns 'satface1, satface2,..., satface6' and I want to make new columns in my data name 'satface1_re, satface_2, ..., satface6_re'. How can I make it?
What I tried was:
data$re <- data %>% select((num_range("satface",1:6,width = 1))) %>%
mutate_all(function(x) recode(x,'1=;2=5;3=4;4=3;5=1;6=1'))
Then new columns were made like 're.satface1, re.satface2,..., re.satface6'
Sample data:
To create new columns with the suffix
_re
, you can subsetdf
and usepaste
:Result: