Frank -
I think you need to create a composite time variable
to do what you want to do:
exp1.r5$key = with(exp1.r5,paste(CannonAngle,CannonOriB,
CannonOriR,nRedPelelts,TargetColor,tbearing,sep='.'))
exp1.r5.use = subset(exp1.r5,select=-c(CannonAngle,CannonOriB,
CannonOriR,nRedPelelts,TargetColor,tbearing))
exp1.r5.wide <- reshape(exp1.r5.use, idvar="Subject", direction =
"wide",
v.names="RT", timevar = 'key')
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spector at stat.berkeley.edu
On Fri, 5 Mar 2010, Frank Tamborello wrote:
> Hi. I have repeated measures data of the form where each observation
> is a trial, and trials are grouped by subject, and variables encode
> whatever level of a factor was present during that trial, and the
> dependent variable is response time (RT). I want to transpose the
> data to a form suitable for MANOVA such that there is one observation
> per subject and RT is recoded across many variables, the totality of
> which represents all the combinations of all the levels of all the
> independent variables.
>
> For example, exp1.r5 is my data frame, Subject is the grouping
> variable, I want to go from long to wide, the dependent variable is
> RT, and I want to get RT as observed at each combination of each
> level of all the variables listed in the timevar argument:
> exp1.r5.wide <- reshape(exp1.r5, idvar="Subject", direction =
"wide",
> sep = "", v.names="RT", timevar =
c("CannonAngle", "CannonOriB",
> "CannonOriR", "nRedPellets", "TargetColor",
"tbearing"))
>
> Instead what I get is Subject plus six variables that are some sort
> of conjunctions of all the levels of each of the variables I want.
> Instead what I want is Subject plus up to 1,008 variables encoding RT
> at every combination of CannonAngle, CannonOriB, CannonOriR,
> nRedPelelts, TargetColor, and tbearing that occurred. Is that
> something the reshape function can give me or should I be looking
> elsewhere?
>
> Sincerely,
>
> Frank Tamborello, PhD
> W. M. Keck Postdoctoral Fellow
> School of Health Information Sciences
> University of Texas Health Science Center, Houston
>
>
> [[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.
>