?reshape
On 28/08/2009, at 11:37 AM, Richardson, Patrick wrote:
I have a dataset that I'm trying to rearrange for a repeated
measures analysis:
It looks like:
patient basefev1 fev11h fev12h fev13h fev14h fev15h fev16h fev17h
fev18h drug
201 2.46 2.68 2.76 2.50 2.30 2.14 2.40 2.33
2.20 a
202 3.50 3.95 3.65 2.93 2.53 3.04 3.37 3.14
2.62 a
203 1.96 2.28 2.34 2.29 2.43 2.06 2.18 2.28
2.29 a
204 3.44 4.08 3.87 3.79 3.30 3.80 3.24 2.98
2.91 a
And I want to make it look like:
Patient FEV time drug
201 2.46 0 a
201 2.68 1 a
201 2.76 2 a
201 2.50 3 a
And so on . . . . . There would be 9 "time" and drug is a factor
variable.
I know there is a way to do this in R but I cannot remember the
function. I've looked at the transpose function in (base) but that
doesn't seem to be what I want. Can something like this be done
easily from within package functions or would it require writing
something custom? Another program would use something like the
transpose procedure, but I'm trying to stay away from that program.
Thanks,
Patrick
######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
______________________________________________
R-help@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.