[R] boxplot question

Peter Whiting pete at sprint.net
Mon Aug 25 14:11:04 CEST 2003


Using the example in the boxplot documentation:

 data(InsectSprays)

I'd like to create two boxplots (one on top of the other) the
first showing the stats for the full data-set and the second
showing the stats for a subset. For the sake of example assume
I want to show in the bottom plot the dist for only points with
count>6.

I set it up as follows:

 layout(matrix(c(1,2,),2,1))
 boxplot(count ~ spray, data = InsectSprays)
 boxplot(count ~ spray, data = InsectSprays, subset=count>6)

However, notice the bottom boxplot's x-axis is different from
the upper boxplot's x-axis. This is because E isn't represented
in the subset. 

How can I create the bottom boxplot such that E is included but
empty, allowing top and bottom plots to line-up for comparison?

pete




More information about the R-help mailing list