[R] creating multiple plots using a splitting factor

Gabor Grothendieck ggrothendieck at gmail.com
Tue Nov 10 01:21:41 CET 2009


   hist(distance_cm, breaks = 10)
is the **output** of a function and is not itself a function.

On the other hand,
    function(distance_cm) hist(distance_cm, breaks = 10)
is a function.

On Mon, Nov 9, 2009 at 7:01 PM, Johnston, Danielle
<Danielle.Bilyeu at state.co.us> wrote:
> 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
> 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