[R] Odp: creating multiple plots using a splitting factor

Petr PIKAL petr.pikal at precheza.cz
Tue Nov 10 08:30:40 CET 2009


Hi

r-help-bounces at r-project.org napsal dne 10.11.2009 01:01:06:

> Hello,
> 
> 
> 
> I am new to R.  I often collect data at multiple sites and need to
> create separate graphs (such as scatterplots or histograms) of specific
> variables for each site.  I have tried to do this by splitting the data

You could also consider lattice and/or ggplot2 packages for that.

Regards
Petr

> frame and then using lapply, but it seems that the graphing commands
> cannot be called as functions.  Here is a sample of my data, called
> "seeddist2":
> 
> 
> 
>    site    DaysSinceRelease   distance_cm
> 
> 10  GVM       1           17.8
> 
> 11  GVM       1           17.8
> 
> 12  GVM       1           14.0
> 
> 13  GVM       1           14.0
> 
> 14  GVM       1           14.9
> 
> 15  GVM       1           25.4
> 
> 16  WRR       1           25.4
> 
> 17  WRR       1           35.0
> 
> 18  WRR       1           45.0
> 
> 19  WRR       1           55.0
> 
> 20  WRR       1           60.0
> 
> 
> 
> Here is what I tried to get separate histograms of distance_cm by site:
> 
> splitlist<- split(seeddist2, site)
> 
> lapply(splitlist, hist(distance_cm, breaks=10))
> 
> 
> 
> I then get an error message saying that "match.fun" didn't find the
> function.  Is there another way to produce multiple graphs at once?
> 
> 
> 
> Thank you,
> 
> 
> 
> Danielle B. Johnston, Habitat Researcher
> 
> Colorado Division of Wildlife
> 
> 
> 
> 
>    [[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.




More information about the R-help mailing list