[R] Creating variable names
Pierre Kleiber
pkleiber at honlab.nmfs.hawaii.edu
Wed Apr 21 00:25:34 CEST 2004
If I understand your problem, it's easy in R too....
> x<-("mydates")
> y<-c("foo1","foo2","foo3") #where "foon" were vectors
> plot(x,y[1],type="n")
> for(i in seq(length(y))) points(x, get(y[1]), pch=i)
>
Cheers, Pierre
Gene Hammel wrote:
> 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.
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
--
-----------------------------------------------------------------
Pierre Kleiber, Ph.D Email: pkleiber at honlab.nmfs.hawaii.edu
Fishery Biologist Tel: 808 983-5399/737-7544
NOAA FISHERIES - Honolulu Laboratory Fax: 808 983-2902
2570 Dole St., Honolulu, HI 96822-2396
-----------------------------------------------------------------
"God could have told Moses about galaxies and mitochondria and
all. But behold... It was good enough for government work."
More information about the R-help
mailing list