I have a large dataset with questionnaire data at multiple time points (waves). The questionnaire was identical at each point, so variables are labeled by time in the form "w#variablename" (e.g., "w1age", "w2age", "w3age").
I split the larger file into data frames by each time point, so I would now like to remove the "w#" from the column name for each column.
Basically, I would like to use R to "find and replace" to delete any column with "w1".
I split the data as follows:
w1 = Data %>% select(matches("w1"))
w2 = Data %>% select(matches("w2"))
w3 = Data %>% select(matches("w3"))
w4 = Data %>% select(matches("w4"))
Now for each of these 4 data sets, I would like to remove the respective "w#" from column names.
Thank you!