My data looks something like this:
myData <- data.frame(v1 = rnorm(10), GP1 = rnorm(10), GP2 = rnorm(10))
I would like to rename all the columns that start with GP
to originalName_something
That is:
myData2 <- data.frame(v1 = rnorm(10), GP1_something = rnorm(10), GP2_something = rnorm(10))
How can i do that? I imagine this should be possible with rename_if
and contains
but i'm not sure how to do it myData %>% rename_if(contains('GP'), paste0(colnames(.),'_something'))
does not work