[R] Looping and Pasting

From: Mark Orr <morrcat_at_gmail.com>
Date: Fri, 22 Feb 2008 15:06:55 -0500


Hello R-community: Much of the time I want to use loops to look at graphs, etc. For example,

I have 25 plots, for which the names are m.1$medoids, m.2$medoids, ..., m.25$medoids.
I want to index the object number (1:25) as below (just to show concept).

for (i in 1:25){
plot(m.i$medoids)
}

I've tried the following, with negative results

for ...
plot(paste("m.",i,"$medoids",sep=""))

for ..
plot(get(paste("m.",i,"$medoids",sep="")))

for...
plot(eval(paste("m.",i,"$medoids",sep="")))

I'm not very fluent with R, but would like to have the general capacity to run loops in this fashion. help and archives did not help me, although I'm sure I've either missed something or did not properly understand the internals of R.

Any help or alternatives are much welcome; however, note, that alternatives should be general, because I desire this functionality for other tasks.

Thanks in advance,

Mark Orr

        [[alternative HTML version deleted]]



R-help_at_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. Received on Fri 22 Feb 2008 - 20:15:33 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 22 Feb 2008 - 21:30:16 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive