[R] graphs for pretest data

hadley wickham h.wickham at gmail.com
Sat Aug 23 20:28:18 CEST 2008


On Sat, Aug 23, 2008 at 1:10 PM, Michael Kubovy <kubovy at virginia.edu> wrote:
> Dear Juliet,
>
> Perhaps start here:
>
> require(lattice)
> mwpp <- data.frame(y = c(43,42,26,39,60,60,46,40,41,36,42,54,
>        58,43,46,56,81,56,70,70,44,52,81,59,69,68),
>        sex = rep(c(rep('men', 14), rep('women', 12))),
>        pp = c(rep(c('pre', 'post'), each = 7), rep(c('pre', 'post'), each =
> 6)),
>        sub = c(1:7, 1:7, 8:13, 8:13))

Or in ggplot2:

library(ggplot2)
qplot(pp, y, data=mwpp, geom=c("point","line"), group = sub, colour=sex)
qplot(pp, y, data=mwpp, geom=c("point","line"), group = sub, facets = .  ~ sex)

The key is to get your data into a data frame with variables that
explicitly label the experimental units, as Michael did for you.

Hadley


-- 
http://had.co.nz/



More information about the R-help mailing list