[R] Help with beanplot fromatting

James Widman jwidman at mi.nmfs.gov
Thu Dec 10 20:23:56 CET 2009

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
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", 


James C. Widman Jr.
Research Fishery Biologist
NOAA Fisheries
Milford, CT

More information about the R-help mailing list