[R] Help with beanplot fromatting

Uwe Ligges ligges at statistik.tu-dortmund.de
Fri Dec 11 11:31:12 CET 2009


Easiest way is probably to make grouprep a factor and insert a level 
without observations such as in:

mydata$grouprep <- factor(mydata$grouprep, levels =
   paste(rep(LETTERS[1:5], each=2), paste("grp", 1:2, sep="")))
beanplot(val~grouprep, data = mydata, ll = 0.04,
   main = "example", ylab = "Size", xlab = "tank",
   side = "both",  border = NA,
   col = list(c("blue", "white"), c("red", "yellow")))

Uwe Ligges




James Widman wrote:
> Sorry for the previous error.
> 
> Dear Helpful R Users,
> 
> I am graphing some data using the beanplot, but I am having trouble 
> getting the output I desire. I have five tanks (A-E) and 2 groups for 
> each tank grp1 or grp2, except tank C where there is only grp1. (I only 
> changed the grouprep to "C grp1" for the example) When I plot them,  I 
> would like A B C(only grp1 - half of the bean plot) then D and E (as 
> full beans). I assume there is some way to do this, but searching the 
> help archives, I haven't been able to find it.
> 
> I would also like to thank all of you, for your answers to others 
> questions, I have been gathering many useful tips.
> 
> # example
> library(beanplot)
> mydata <- data.frame(tank = rep(c("A","B","C","D","E"), 
> c(100,100,50,100,100)), group = rep(c("grp1", "grp2")), val = rnorm(450))
> mydata$grouprep <- paste( mydata$tank,  mydata$group)
> mydata$grouprep <-with(mydata, ifelse((tank=="C"), "C grp1", grouprep))
> beanplot(val~grouprep, data = mydata, ll = 0.04,
>  main = "example", ylab = "Size",
>  xlab = "tank",
>  side = "both",  border = NA, col = list(c("blue", "white"), c("red", 
> "yellow")))
> 
> Thanks,
> Jim
> 
> James C. Widman Jr.
> Research Fishery Biologist
> NOAA Fisheries
> Milford, CT
> 
> ______________________________________________
> 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