Ash
Ash

Reputation: 237

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.

Upvotes: 1

Views: 2102

Answers (1)

zx8754
zx8754

Reputation: 56189

Try this:

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

Upvotes: 3

Related Questions