[R] Pivoting a data.frame

Athula Herath (Athula.Herath@ogs.co.uk)
Tue, 10 Nov 1998 12:14:13 +0000

Date: Tue, 10 Nov 1998 12:14:13 +0000
From: Athula Herath <Athula.Herath@ogs.co.uk>
To: r-help@stat.math.ethz.ch
Subject: [R] Pivoting a data.frame

Hi,

I would like tranform a data.frame which has a structure similar to the:

Col1 Col2 Col3
B1 1 0.3
B1 2 0.4
B1 3 0.3
B2 1 0.2
B2 2 0.2
B2 5 0.4
B2 6 0.1
B3 1 0.2
B3 2 0.1
B3 5 0.2

[Data Frame 1]

Into the following structure (pivoting or transpose is
being used sometimes to describe this, I believe).

B1 B2 B3
1 0.3 0.2 0.2
2 0.4 0.2 0.1
3 0.3 NA NA
5 NA 0.4 0.2
6 NA 0.1 NA

[Data Frame 22]

As you see above, the columns of Table 1 is rearrange to
categorise the third column (in terms of Col1 and Col2).

I wonder whether anybody here could help me to code this
in S-Plus or R, or point me on the direction how to do
this.


Many Thanks,

Athula.

-- 
Athula Herath, PhD, CEng, MBCS, Biostatistician
Oxford GlycoSciences,10, The Quadrant
Abingdon Science Park, Abingdon, OXON OX14 3YS
Email:Athula.Herath@ogs.co.uk Phone:+44 [0]1235 544202  FAX:+44 [0]1235
554701
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


This archive was generated by hypermail 1.02.