[R] transposing data

Frank Tamborello
Sat, 06 Mar 2010 04:05:49 -0000

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]]