[R] Manipulating dataframe

Ravi Varadhan rvaradha at jhsph.edu
Fri Nov 1 21:16:32 CET 2002


Hi:

Suppose, I have a dataframe (with N rows) containing the following 
variables:

ID  X82  X85  X88 

>From this, I'd like to create a new dataframe (with 3*N rows), which 
will have the following variables:

ID  X82  X85  X88  Xrep

where: each ID is duplicated 3 times; X82 equals its original value for 
the first row and equals NA for the other two; X85 equals its original 
value for the second row and equals NA for the other two; X88 equals 
its original value for the third row and equals NA for the other two; 
Xrep will equal X82, X85 and X88 in the first, second and third rows, 
respectively.

Is there an efficient way to do this?

Thanks for any help,
Ravi.


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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 at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list