[R] ggplot output

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Thu Nov 4 14:55:23 CET 2010


The easiest way it to create one long dataset with four variables:
Month, avg, stdev and type. Type will be either K, C or S.
Then you just need to add some facetting to your code

ggplot(data = dat, aes(x = Month, y = avg, ymin = avg - stdev, ymax =
avg + stdev)) +
   geom_point() +
   geom_line() +
   geom_errorbar() +
   facet_wrap(~type, nrow = 1)

HTH,

Thierry

------------------------------------------------------------------------
----
ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek
team Biometrie & Kwaliteitszorg
Gaverstraat 4
9500 Geraardsbergen
Belgium

Research Institute for Nature and Forest
team Biometrics & Quality Assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium

tel. + 32 54/436 185
Thierry.Onkelinx op 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 op r-project.org 
> [mailto:r-help-bounces op r-project.org] Namens ashz
> Verzonden: donderdag 4 november 2010 14:37
> Aan: r-help op r-project.org
> Onderwerp: [R] ggplot output
> 
> 
> Dear All, 
> 
> I have this script:
> 
> dat <- data.frame(Month = hstat$Date,C_avg = hstat$C.avg,C_stdev =
> hstat$C.stdev)
> ggplot(data = dat, aes(x = Month, y = C_avg, ymin = C_avg - 
> C_stdev, ymax = C_avg + C_stdev)) +
>   geom_point() +
>   geom_line() +
>   geom_errorbar()
>   
> dat <- data.frame(Month = hstat$Date,K_avg = hstat$K.avg,K_stdev =
> hstat$K.stdev)
> ggplot(data = dat, aes(x = Month, y = K_avg, ymin = K_avg - 
> K_stdev, ymax = K_avg + K_stdev)) +
>   geom_point() +
>   geom_line() +
>   geom_errorbar()
>   
> dat <- data.frame(Month = hstat$Date,S_avg = hstat$S.avg,S_stdev =
> hstat$S.stdev)
> ggplot(data = dat, aes(x = Month, y = S_avg, ymin = S_avg - 
> S_stdev, ymax = S_avg + S_stdev)) +
>   geom_point() +
>   geom_line() +
>   geom_errorbar()
> 
> Running the script generates 3 separate graphs, how can I 
> output them next to each other?  
> 
> Thanks
> 
> --
> View this message in context: 
> http://r.789695.n4.nabble.com/ggplot-output-tp3027026p3027026.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help op 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