[R] Collapsing across trials
hadley wickham
h.wickham at gmail.com
Sun Dec 17 07:34:00 CET 2006
On 12/16/06, Pedro Alcocer <pealco at gmail.com> wrote:
> Hello,
>
> My ultimate goal is a repeated measures (mixed model) ANOVA, however,
> my present question is about how to reorganize my data into the format
> that the ANOVA commands expect. In particular, how to collapse across
> trials. (I am using the tutorial at
> [http://personality-project.org/r/r.anova.html] for the mixed model
> ANOVA)
>
> The data I am using looks like this. A subject sees 10 trials per
> condition and there are 2 conditions. I want the average of all the
> reaction times (RTs) from a subject looking a one condition. I also
> want to retain List in the final output.
Have a look at the reshape package, http://had.co.nz/reshape.
The following code should do what you want:
install.packages("reshape")
library(reshape)
dfm <- melt(df, id=c("Subj", "List","Condition"))
cast(Subj + List + Condition ~ variable , mean)
(that should work with any number of rt variables)
Hadley
More information about the R-help
mailing list