[R] processing subset lists and then plot(density())

stephen sefick ssefick at gmail.com
Tue Aug 26 16:33:03 CEST 2008


definitly need to look into ggplot- very cool.
thanks

On Tue, Aug 26, 2008 at 10:20 AM, ONKELINX, Thierry
<Thierry.ONKELINX at inbo.be> wrote:
>
> Here's a solution with ggplot2
>
> library(ggplot2)
> ggplot(na.omit(d), aes(x = EPT.Taxa, colour = Site)) + geom_density()
> ggplot(na.omit(d), aes(x = EPT.Taxa)) + geom_density() + facet_grid(Site
> ~ .)
>
> HTH,
>
> Thierry
>
>
> ------------------------------------------------------------------------
> ----
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Research Institute for Nature
> and Forest
> Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
> methodology and quality assurance
> Gaverstraat 4
> 9500 Geraardsbergen
> Belgium
> tel. + 32 54/436 185
> Thierry.Onkelinx at inbo.be
> www.inbo.be
>
> To call in the statistician after the experiment is done may be no more
> than asking him to perform a post-mortem examination: he may be able to
> say what the experiment died of.
> ~ Sir Ronald Aylmer Fisher
>
> The plural of anecdote is not data.
> ~ Roger Brinner
>
> The combination of some data and an aching desire for an answer does not
> ensure that a reasonable answer can be extracted from a given body of
> data.
> ~ John Tukey
>
> -----Oorspronkelijk bericht-----
> Van: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
> Namens stephen sefick
> Verzonden: dinsdag 26 augustus 2008 15:51
> Aan: R Help
> Onderwerp: [R] processing subset lists and then plot(density())
>
> d <- structure(list(Site = structure(c(8L, 12L, 7L, 6L, 11L, 5L, 10L,
> 4L, 3L, 2L, 1L, 9L, 8L, 12L, 7L, 6L, 11L, 5L, 10L, 4L, 3L, 2L,
> 1L, 9L, 8L, 12L, 7L, 6L, 11L, 5L, 10L, 4L, 3L, 2L, 1L, 9L, 8L,
> 12L, 7L, 6L, 11L, 5L, 10L, 4L, 3L, 2L, 1L, 9L, 8L, 12L, 7L, 6L,
> 11L, 5L, 10L, 4L, 3L, 2L, 1L, 9L, 8L, 12L, 7L, 6L, 11L, 5L, 10L,
> 4L, 3L, 2L, 1L, 9L, 8L, 12L, 7L, 6L, 11L, 5L, 10L, 4L, 3L, 2L,
> 1L, 9L, 8L, 12L, 7L, 6L, 11L, 5L, 10L, 4L, 3L, 2L, 1L, 9L, 8L,
> 12L, 7L, 6L, 11L, 5L, 10L, 4L, 3L, 2L, 1L, 9L, 8L, 12L, 7L, 6L,
> 11L, 5L, 10L, 4L, 3L, 2L, 1L, 9L, 8L, 12L, 7L, 6L, 11L, 5L, 10L,
> 4L, 3L, 2L, 1L, 9L, 8L, 12L, 7L, 6L, 11L, 5L, 10L, 4L, 3L, 2L,
> 1L, 9L), .Label = c("119", "148", "179", "185", "190", "198",
> "202", "215", "61", "BC", "HC", "SC"), class = "factor"), EPT.Taxa =
> c(NA,
> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
> NA, NA, NA, 1L, NA, 3L, 1L, 5L, 7L, 3L, 11L, 3L, 14L, 12L, 12L,
> 0L, 0L, 4L, 0L, 5L, 3L, 2L, 6L, 1L, 8L, 6L, 9L, 1L, 0L, 2L, 0L,
> 5L, 2L, 1L, 0L, 2L, 4L, 6L, 8L, NA, NA, NA, NA, NA, NA, NA, NA,
> NA, NA, NA, NA, 2L, 4L, 3L, 2L, 7L, 6L, 4L, 8L, 7L, 11L, 8L,
> 11L, 1L, 3L, 0L, 2L, 7L, 8L, 2L, 7L, 6L, 11L, 6L, 12L, 1L, 1L,
> 0L, 0L, 0L, 1L, 2L, 9L, 6L, 16L, 6L, 10L, 2L, 3L, 3L, 2L, 5L,
> 2L, 0L, 3L, 6L, 10L, NA, 10L, 1L, 0L, 3L, 1L, 4L, 2L, 3L, 2L,
> 3L, 11L, 10L, 6L)), .Names = c("Site", "EPT.Taxa"), class =
> "data.frame", row.names = c(NA,
> -144L))
> subset(d, Site==215)
> #I would like to plot(density()) of each of the Sites
> #I tried
> list<-levels(d$Site)
> lapply(d, FUN=subset, Site==list)
> #I would like to be able to make a list of the subsets based on Site
> and then plot them all on one graphics window
> # Am I working in the right direction- I have just discovered lists (I
> know I know, I am a little slow)
> --
> Stephen Sefick
> Research Scientist
> Southeastern Natural Sciences Academy
>
> Let's not spend our time and resources thinking about things that are
> so little or so large that all they really do for us is puff us up and
> make us feel like gods. We are mammals, and have not exhausted the
> annoying little problems of being mammals.
>
>        -K. Mullis
>
> ______________________________________________
> 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.
>
> Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document.
> The views expressed in  this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document
>



-- 
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods. We are mammals, and have not exhausted the
annoying little problems of being mammals.

	-K. Mullis



More information about the R-help mailing list