[R] Rename variables starting with digits

Anne Zach @nne@z@ch@z@ch @end|ng |rom gm@||@com
Mon Oct 4 20:02:36 CEST 2021

Dear R users,

I have a dataframe that contains several variables, among which 105
correspond to scores on certain trials. Unfortunately, when I imported this
dataframe into R, I realised that the variable names corresponding to each
trial begin with digits, which violates R naming conventions.

I am trying to relabel these variables by adding a 'v' as a prefix to each
of them, I'd like to use tidyverse, but I am struggling with this process
of renaming. When I run this chunk of code, no error occurs but my
variables are not renamed. I'm fairly new to R and I can't understand what
I'm doing wrong.


behavioral_df <- behavioral_df %>% rename_with(.fn =  ~paste0("v"),


I appreciate if you can help.


	[[alternative HTML version deleted]]

More information about the R-help mailing list