[R] Loop over several Variables, add on question
bchr
bochristoph at web.de
Fri Nov 2 11:56:40 CET 2012
Hey everyone,
I have again a loop question:
After generating the dataset using Jan’s approach from my previous posting
(http://r.789695.n4.nabble.com/Loop-over-several-variables-td4648112.html) I
want to rename the Variables in the new dataset so that all y will be called
tiy. Doing it separately the following line works fine:
ti<-rename (ti,c(y5="tiy5"))
So I thought I simply extend to the following and the loop will be fine:
ti<-rename (ti,c([paste0("y", 1:5)] = [paste0("tiy", 1:5)]))
However, this will give me the following error message:
Error: unexpected '[' in "ti<-rename (ti,c(["
Removing the “[“ I then used the following line
ti<-rename (ti,c(paste0("y", 1:5) = paste0("tiy", 1:5)))
This provoked the following error:
Error: unexpected '=' in "ti<-rename (ti,c(paste0("y", 1:5) ="
I did some playing around with the brackets but I could not stop R from
sending an error about the equal sign. Anybody any Idea where my mistake
might be?
Thanks in advance
Bernhard
--
View this message in context: http://r.789695.n4.nabble.com/Loop-over-several-Variables-add-on-question-tp4648216.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list