[R] Creating variable names

Gene Hammel genehammel at comcast.net
Tue Apr 20 23:52:17 CEST 2004


My apologies for asking what is doubtless a dumb question, but I have 
scant experience in R.
It would be very convenient in doing lots of plots to be able to do them 
in a loop that stepped through a vector of variable names. For example 
one could say

x<-("mydates")
y<-c("foo1","foo2","foo3") #where "foon" were vectors
plot(x,y[1],type="n")
points(x,y[1])
points(x,y[2],pch=2)
points(x,y[3],pch=3)

This is pretty easy in Perl, but of course Perl is not for plotting. Of 
course one could construct a data structure in R that would hold what 
was wanted and maybe that is the way to go. But I thought I would ask, 
if you have the patience to get this far with what is, I suspect, a 
silly question from a novice.

Thanks.




More information about the R-help mailing list