[R] add group to boxplot

Karin Lagesen karin.lagesen at medisin.uio.no
Mon Sep 17 15:25:55 CEST 2007



I have two sets of data in data frames (different dimensions). Now, I
am able to make boxplots for one of these. I am using a formula, which
gives me three boxplots which is automatically placed at at = c(1:3),
since there are three groups. However, I would now like to add data
from the other data frame, at position 4 in the box plot. Is there any
way of telling the first boxplot command that this should be allowed?

Hopefully an example that expresses what I need:

> data(InsectSprays)
> boxplot(count~spray, data = InsectSprays)
> Aspray = subset(InsectSprays, spray == "A")
> Aspray[] = lapply(Aspray, function(x) if (is.factor(x)) factor(x) else x)

Now, I want to add Aspray as a new boxplot at the end of the existing plot,

What do I do then?


Karin
-- 
Karin Lagesen, PhD student
karin.lagesen at medisin.uio.no
http://folk.uio.no/karinlag



More information about the R-help mailing list