Dear all,

I have following codes:

colnames(data) = c("var", "var", "var")
i = c(1,2,3)

Now I want construct a "for" loop starting from 1 to 3 to give the new names of 
columns for dataframe "data" like below

colnames(data) 
> c("var1", "var2", "var3")

Definitely I could do this manually, however I want to put this in a automated 
way so that I can do this for any number of columns.

Can anyone here tell me how to do that?

Thanks and regards,
Megh

       
---------------------------------

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to