[R] automatically generate the output name of my "for" loops

Vijayanpadmanabhan v.padmanabhan at itc.in
Mon Jun 13 17:55:04 CEST 2011


Hi Daniel
Try using this approach....
 
##Drawing analogy from your example.. I am storing the values generated in a
loop in the following code
 
for (i in c(1:100))
 {
 nam <- paste("r",i, sep=".")
 assign(nam, i+1)
 }
 
##Having stored the values generated in the above loop in as many R
objects..Here is how you extract them..
 
for (i in c(1:100))
 {
print(get(paste("r",i, sep=".")) )
}
 
Trust it helps.
Regards
Vijayan Padmanabhan

--
View this message in context: http://r.789695.n4.nabble.com/automatically-generate-the-output-name-of-my-for-loops-tp3592160p3594160.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list