Search code examples
rvariablesdataframeprefix

Prefix all variable names in R


I want to prefix all variable names in a data frame with b_.

Any ideas how to do this I can't find any similar questions or advice out there.


Solution

  • Try this:

    colnames(df) <- paste0("b_",colnames(df))