Skip to content

Manipulating dataframe

1 message · Ravi Varadhan

#
Hi:

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

ID  X82  X85  X88
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._