I have below data frame
library(dplyr)
data = data.frame('A' = 1:3, 'CC' = 1:3, 'DD' = 1:3, 'M' = 1:3)
Now let define a vectors of strings which represents a subset of column names of above data frame
Target_Col = c('CC', 'M')
Now I want to find the column names in data
that match with Target_Col
and then replace them with
paste0('Prefix_', Target_Col)
I prefer to do it using dplyr
chain rule.
Is there any direct function available to perform this?