[R] using lapply and split to plot up subsets of a vector

Phil Spector spector at stat.berkeley.edu
Wed Dec 29 01:15:37 CET 2010


The data= argument to plot only makes sense if the first 
argument is a formula.  So if you change the plot command
in your function to

        plot(ln.o2con~lnbm,data=df)

you might get what you want.  But I would suggest you take a
look at the plot produced by

library(lattice)
xyplot(ln.o2con~lnbm|sp.id,data=one)

which might be more useful.

 					- Phil Spector
 					 Statistical Computing Facility
 					 Department of Statistics
 					 UC Berkeley
 					 spector at stat.berkeley.edu


On Tue, 28 Dec 2010, karmakiller wrote:

>
> Hi,
>
> I would like to be able to plot data from each of the sp.id on individual
> plots. At the moment I can plot all the data on one graph with the following
> commands but I cannot figure out how to get individual graph for each sp.id.
>
> i<- function(df)plot(lnbm,ln.o2con,data=df)
> j<- lapply(split(one,one$sp.id),i)
>
> I have searched on the net and through the threads here but I cannot find
> anything that matches what I am trying to do. Any help would be greatly
> appreciated.
>
> Thanx
> -- 
> View this message in context: http://r.789695.n4.nabble.com/using-lapply-and-split-to-plot-up-subsets-of-a-vector-tp3166634p3166634.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list