Skip to content
Prev 309663 / 398503 Next

Loop over several Variables, add on question

Hi

please put your messages in context. Not everybody is able/allowed to use Nabble.
Hm. No data, no structure of ti. Hm. Hm. Just let me look into my crystal ball. You want to change names of columns in data frame ti

names(ti) gives you a vector of names

names(ti)[grep("y", names(ti))]

selects relevant names

names(ti)[grep("y", names(ti))] <- paste0("tiy", 1:5)

changes respective names.

If you read only few pages (about 20) from R-intro, which you shall have installed together with R, you probably will find many basic operations with objects, distinctions among various object types and how to check your objects. The reading shall not take so long and maybe you will find after that reading it was the best spent time ever in your R learning.

Regards
Petr