This is nearly right:
reshape(t1, direction="wide", idvar="id",
timevar="aspect")
id score.A score.B
1 1 10 9
3 2 11 12
Simon.
Simon Blomberg, PhD
Depression & Anxiety Consumer Research Unit
Centre for Mental Health Research
Australian National University
http://www.anu.edu.au/cmhr/
Simon.Blomberg at anu.edu.au +61 (2) 6125 3379
> -----Original Message-----
> From: Andrew C. Ward [mailto:s195404 at student.uq.edu.au]
> Sent: Thursday, 30 October 2003 3:28 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] Trouble reshaping some data
>
>
> I would appreciate some advice on the following task. I have
> some data that currently looks like this:
> t1 <- data.frame(id=c(1,1,2,2),
> aspect=c("A","B","A","B"),
score=c(10,9,11,12))
>
> I'd like it to look like this:
> id A B
> 1 10 9
> 2 11 12
>
> reshape() looks like a good candidate for this job but I'm
> not really sure about the roles of timevar and idvar for
> this dataframe. I tried
> t2 <- reshape(t1, direction="wide", timevar=t1[,3],
> idvar=t1[,2])
> which is obviously ignorant and wrong.
>
> Thank you in advance for any comments.
>
>
> Regards,
>
> Andrew C. Ward
>
> CAPE Centre
> Department of Chemical Engineering
> The University of Queensland
> Brisbane Qld 4072 Australia
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>