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.
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."
Gene Hammel <genehammel at comcast.net> writes:> 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")You misquoted that line. There is no function before the (> 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) >The general approach in R is often called "whole object". That is, you try to put your data into a structure that will facilitate the operations you wish to perform. In this case bind the responses into a matrix and use matplot matplot(x, cbind(foo1, foo2, foo3), type = 'p') -- Douglas Bates bates at stat.wisc.edu Statistics Department 608/262-2598 University of Wisconsin - Madison http://www.stat.wisc.edu/~bates/