[R] FW: reshape dataframe

Duijvesteijn, Naomi Naomi.Duijvesteijn at ipg.nl
Fri Mar 20 15:41:39 CET 2009


   Hi,


   I have a large dataset on which I would like to do the following:


   x<-data.frame(id=c(1,2,3), snp1=c("AA","GG",
   "AG"),snp2=c("GG","AG","GG"),snp3=c("GG","AG","AA"))

   > x

     id snp1 snp2 snp3

   1  1   AA   GG   GG

   2  2   GG   AG   AG

   3  3   AG   GG   AA


   And  then reshape the dataset in such a way that the individuals get 2
   observations for every snp by splitting the genotypes (in this case):


   id snp1 snp2 snp3

   1 A G A

   1 A G G

   2 G A G

   2 G G G

   3 G A A

   3 G G A


   It is probably quite easy to solve, but I can’t get it right…


   Thanks for your help and valuable time!


   Naomi Duijvesteijn



   
   
   
   Disclaimer:  De  informatie opgenomen in dit bericht (en bijlagen) kan
   vertrouwelijk zijn en is uitsluitend bestemd voor de geadresseerde(n).
   Indien u dit bericht ten onrechte ontvangt, wordt u geacht de inhoud niet te
   gebruiken, de afzender direct te informeren en het bericht te vernietigen.
   Aan dit bericht kunnen geen rechten of plichten worden ontleend.

   ----------------------------------------------------------------------------
   ----------------------------

   Disclaimer: The information contained in this message may be confidential
   and is intended to be exclusively for the addressee. Should you receive this
   message unintentionally, you are expected not to use the contents herein, to
   notify the sender immediately and to destroy the message. No rights can be
   derived from this message.


More information about the R-help mailing list