Here is a brute force way:
mm <- NULL
for(i in unique(ID)){
zz <- data.frame[ID==i, 3]
mm <- rbind(mm, c(i, zz))
}
It will work as long as you have the same number of tests for each ID. If
not, you would need to pad shorter zz vectors with NAs.
Cheers,
Andy
__________________________________
Andy Jaworski
Engineering Systems Technology Center
3M Center, 518-1-01
St. Paul, MN 55144-1000
-----
E-mail: [EMAIL PROTECTED]
Tel: (651) 733-6092
Fax: (651) 736-3122
|---------+-------------------------------->
| | Bruce Coate |
| | <[EMAIL PROTECTED]|
| | m> |
| | Sent by: |
| | [EMAIL PROTECTED]|
| | ath.ethz.ch |
| | |
| | |
| | 09/17/2003 12:30 |
| | |
|---------+-------------------------------->
>-----------------------------------------------------------------------------------------------------------------------------|
|
|
| To: [EMAIL PROTECTED]
|
| cc:
|
| Subject: [R] Transpose Data Frame Question
|
>-----------------------------------------------------------------------------------------------------------------------------|
Hi,
I have a data.frame that has 3 columns (ID, Test, Result) and looks like
this
1, Test1, 120
1, Test2, 34
2, Test1, 132
2, Test2, 28
etc
I would like to turn it around so that it looks like this
1, 120, 34
2, 132, 28
etc
I have played around some with t and reshape, but with no success.
Any suggestions or hints would be greatly appreciated.
Thanks,
Bruce
---------------------------------
[[alternative HTML version deleted]]
______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help