Hi all,
I want to make extra columns in my datafile where the id of every groupmember is mentioned in separate columns. To explain it better see the example: id<-c(1,2,3,4,5,6,7,8,9,10,11,12) group<-c(1,1,1,1,2,2,3,3,3,3,3,3) a<-as.data.frame(cbind(id,group)) a id group 1 1 1 2 2 1 3 3 1 4 4 1 5 5 2 6 6 2 7 7 3 8 8 3 9 9 3 10 10 3 11 11 3 12 12 3 Result should be (gm = groupmember) id group gm1 gm2 gm3 gm4 gm5 gm6 gm7 etc. 1 1 2 3 4 NA NA NA NA 2 1 1 3 4 NA NA NA NA 3 1 1 2 4 NA NA NA NA 4 1 1 2 3 NA NA NA NA 5 2 6 NA NA NA NA NA NA 6 2 5 NA NA NA NA NA NA 7 3 8 9 10 11 12 NA NA 8 3 7 9 10 11 12 NA NA 9 3 7 8 10 11 12 NA NA 10 3 7 8 9 11 12 NA NA 11 3 7 8 9 10 12 NA NA 12 3 7 8 9 10 11 NA NA What I have been trying so far is reshape, but this doesnât put the idâs of the groupmembers of different groups under the same columnname. It makes new columnnames per group. Couls somebody help me out with this? I really appreciate it Regards, 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. P Please consider the environment before printing this email
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.