[R] A rebel boxplot question

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Thu Oct 4 17:59:53 CEST 2007


I've altered the code slightly so one group has no data in one month.

  library(ggplot2)
  dataset <- data.frame(Month = factor(rep(1:12, 20)),  Value =
c(rnorm(120) + 1:12, rnorm(120) + 12:1), Group = gl(2, 120, labels =
LETTERS[1:2]))
  dataset <- dataset[dataset$Month != 2 | dataset$Group != "A", ]
  ggplot(dataset, aes(x = Month, y = Value, colour = Group)) +
geom_boxplot()

Cheers,

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 op inbo.be
www.inbo.be 

Do not put your faith in what statistics say until you have carefully
considered what they do not say.  ~William W. Watt
A statistical analysis, properly conducted, is a delicate dissection of
uncertainties, a surgery of suppositions. ~M.J.Moroney



> -----Oorspronkelijk bericht-----
> Van: ONKELINX, Thierry 
> Verzonden: donderdag 4 oktober 2007 17:55
> Aan: 'p.valdes op arsystel.com'; r-help op r-project.org
> Onderwerp: RE: [R] A rebel boxplot question
> 
> Merge both datasets into one with a grouping variable. Then 
> have a look at the ggplot2 package.
> 
>   library(ggplot2)
>   dataset <- data.frame(Month = factor(rep(1:12, 20)),  Value 
> = c(rnorm(120) + 1:12, rnorm(120) + 12:1), Group = gl(2, 120, 
> labels = LETTERS[1:2]))
>   ggplot(dataset, aes(x = Month, y = Value, colour = Group)) 
> + geom_boxplot()
> 
> Cheers,
> 
> 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 op inbo.be www.inbo.be 
> 
> Do not put your faith in what statistics say until you have 
> carefully considered what they do not say.  ~William W. Watt 
> A statistical analysis, properly conducted, is a delicate 
> dissection of uncertainties, a surgery of suppositions. ~M.J.Moroney
> 
>  
> 
> > -----Oorspronkelijk bericht-----
> > Van: r-help-bounces op r-project.org
> > [mailto:r-help-bounces op r-project.org] Namens p.valdes op arsystel.com
> > Verzonden: donderdag 4 oktober 2007 17:40
> > Aan: r-help op r-project.org
> > Onderwerp: [R] A rebel boxplot question
> > 
> > Dear R list members
> > I am trying to improve a boxplot with 2 data sets. I run somethinkg 
> > like
> > 
> > boxplot(data1 ~ month, add=F, col = "red", ...)
> > boxplot(data2 ~ month, add=T, col = "blue", ...)
> > 
> > The problem is that the data from February are missing for 
> data2, so R 
> > think that must take little more space between the data classes in 
> > data 2 and then both data gropus are not aligned. In the R 
> > documentation I do not find any posile solution for tell R 
> that I want 
> > reserve a extra space for this month, So the boxplot is 
> erroneous and 
> > the x axis have a strange numeration
> > 
> > 1 2 3 4 54 65 76 ... etc
> > 
> >  I would be grateful if anyone could suggest how to tell R That the 
> > boxplots must be fitted to the same x class in both data groups. To 
> > make a false data group with a 0 valor for february is not 
> aceptable 
> > in this case
> > 
> > Sincerely
> > Pablo Valdes
> > 
> > ______________________________________________
> > 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