[R] ANOVA boxplots

Joshua Wiley jwiley.psych at gmail.com
Wed Oct 6 16:37:33 CEST 2010


Dear Alex,

I would suggest using the lattice package, it handles more complex
formulae beautifully.  Here is an example using an available dataset
and the bwplot() function (which does boxplots).

library(lattice)
bwplot(mpg~factor(cyl)|factor(am), data = mtcars)

Hope that helps,

Josh

On Wed, Oct 6, 2010 at 7:21 AM, Jake Kami <jakejkami at gmail.com> wrote:
> Dear list,
>
> i have a quick and (hopefully) straightforward question regarding the
> plot-function after running aov. if i plot an equation like this:
>
>
> plot(dataSubjects~factorA, data=mydata)
>
>
> R gives me the boxplots for this particular factor A. my model, however
> contains several factors. is there a straightforward way to plot barplots
> for a specific factor with the constraint that those values are taken from
> only the cells of a second factor B? for instance, if A contained three
> different tasks (levels), B two different drug treatments and C three groups
> of patients, and I wanna plot the baoxplots for the different tasks, but
> /only/ for one particular patient group, how can i do this without
> separating the data.frame into several arrays? i tried something like
>
> plot(dataSubjects~factorA|factorC, data=mydata)
>
> but apparently it does not work. Any help on this is highly appreciated.
>
>
>
> cheers
>
> Alex
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/



More information about the R-help mailing list