[R] Comples Boxplots in R . Resources

ONKELINX, Thierry Thierry.ONKELINX at inbo.be
Fri Mar 23 15:04:26 CET 2012


Dear Alex,

Have a look at the ggplot2 package

n <- 3502
junk <- list(list(matrix(rnorm(n), ncol = 1), matrix(rnorm(n, sd = 2), ncol = 1)), list(matrix(rnorm(n, mean = 1), ncol = 1), matrix(rnorm(n, mean = 1, sd = 2), ncol = 1)), list(matrix(rnorm(n, mean = 1), ncol = 1), matrix(rnorm(n, mean = -1, sd = 0.5), ncol = 1)))
dataset <- do.call(rbind, lapply(seq_along(junk), function(i){
 data.frame(set = i, status = c(rep("On", nrow(junk[[i]][[1]])), rep("Off", nrow(junk[[i]][[2]]))), value = unlist(junk[[i]]))
}))
dataset$set <- factor(dataset$set)
library(ggplot2)
ggplot(dataset, aes(x = set, y = value, linetype = status)) + geom_boxplot()


ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest
team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance
Kliniekstraat 25
1070 Anderlecht
Belgium
+ 32 2 525 02 51
+ 32 54 43 61 85
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 R. Michael Weylandt
Verzonden: vrijdag 23 maart 2012 14:09
Aan: Alaios
CC: R help
Onderwerp: Re: [R] Comples Boxplots in R . Resources

Take a look at

example(boxplot)
and
example(bxp)

I think the last one for boxplot (with the guinea pig teeth!) will work for you and I believe you can manipulate the linetype the same way they do color there.  Though looking at your data, it seems problematic that your values are so different....if that's problematic of your real data, you'll need to scale them to match or use multiple facets / panels as the examples demonstrate.

Michael

On Fri, Mar 23, 2012 at 7:05 AM, Alaios <alaios op yahoo.com> wrote:
> Dear all,
> I want to have a box plot for 7 datasets I have. The different here is that each of these 7 data sets has two status . The on and off.
>
> So I give a small example below with 2 data sets only
>
> List of 2
>  $ :List of 2
>   ..$ : num [1:3502, 1] 0 0 0 0 0 0 0 0 0 0 ... # On Status
>   ..$ : num [1:3502, 1] 102884 102884 102884 102884 102884 ... # Off 
> status
>  $ :List of 2
>   ..$ : num [1:3502, 1] 0 0 0 0 0 0 0 0 0 0 ... # On Status
>   ..$ : num [1:3502, 1] 102884 102884 102884 102884 102884 ... # Off 
> status
>
>
> I would like to print all these information in a same boxplot where in each tick instead of having one box, I want it to have two boxes.. one for the on status and one for the off status. Even better it would be great if the on boxes will be plotted by solid lines and the off boxes with dashed lines.
>
> I understand that this is a bit complex, so do you know if there are few references to read how I can do that in R?
>
>  I would like to thank you in advance for your help
>
> B.R
> Alex
>
>        [[alternative HTML version deleted]]
>
>
> ______________________________________________
> 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.
>

______________________________________________
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