Dear R user, I'm relative new and need some help / advise from you. I have organised my data in several frames, mainly because the data came from different sources. One common variable in all data frames is the day post transplantation. I would like to combine the data frame to one big data frame which contains all the data, however no duplicate rows should occour (only one row for one day) Here an example which illustrates what I would like to do: Frame 1 Day Hb wbc 1 10 4 3 11 7 5 9 6 Frame 2 Day ALT 1 60 2 70 4 50 5 80 Combined Day Hb wbc ALT 1 10 4 60 2 NA NA 70 3 11 7 NA 4 NA NA 50 5 9 6 80 Does anyone know if this can be done, or is it better not to combine the frames ? I appreciate any thoughts or help Frank Mattes Department of Virology Royal Free and University Medical School London -- _________________________________________________________ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>>>>> "Frank" == Frank Mattes <list_server2001 at yahoo.com> writes:Frank> Dear R user, I'm relative new and need some help / Frank> advise from you. I have organised my data in several Frank> frames, mainly because the data came from different Frank> sources. One common variable in all data frames is Frank> the day post transplantation. I would like to combine Frank> the data frame to one big data frame which contains Frank> all the data, however no duplicate rows should occour Frank> (only one row for one day) Frank> Here an example which illustrates what I would like Frank> to do: Frank> Frame 1 Frank> Day Hb wbc Frank> 1 10 4 Frank> 3 11 7 Frank> 5 9 6 Frank> Frame 2 Frank> Day ALT Frank> 1 60 Frank> 2 70 Frank> 4 50 Frank> 5 80 Frank> Combined Frank> Day Hb wbc ALT Frank> 1 10 4 60 Frank> 2 NA NA 70 Frank> 3 11 7 NA Frank> 4 NA NA 50 Frank> 5 9 6 80 Frank> Does anyone know if this can be done, "if" is not the question with R -- it's a full programming language -- rather ``how easy''. Answer (in this case "quite easy"): fr12 <- merge(frame1, frame2) should work (using the merge method `merge.data.frame' -- look at its help page for options!) Frank> or is it better not to combine the frames ? (this depends on what you want to do with it; I think I *would* want a combined data frame (and still keep the single ones)) Martin Maechler <maechler at stat.math.ethz.ch> http://stat.ethz.ch/~maechler/ Seminar fuer Statistik, ETH-Zentrum LEO C16 Leonhardstr. 27 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-1-632-3408 fax: ...-1228 <>< -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hello, you can use merge to merge data frames by common columns. See ?merge. best jan On Wed, 06 Mar 2002, Frank Mattes wrote:> Dear R user, > > I'm relative new and need some help / advise from you. I have > organised my data in several frames, mainly because the data came > from different sources. One common variable in all data frames is the > day post transplantation. I would like to combine the data frame to > one big data frame which contains all the data, however no duplicate > rows should occour (only one row for one day) > > Here an example which illustrates what I would like to do: > > Frame 1 > Day Hb wbc > 1 10 4 > 3 11 7 > 5 9 6 > > > Frame 2 > > Day ALT > 1 60 > 2 70 > 4 50 > 5 80 > > Combined > > Day Hb wbc ALT > 1 10 4 60 > 2 NA NA 70 > 3 11 7 NA > 4 NA NA 50 > 5 9 6 80 > > Does anyone know if this can be done, or is it better not to combine > the frames ? > > I appreciate any thoughts or help > > Frank Mattes > Department of Virology > Royal Free and University Medical School > London > -- > > _________________________________________________________ > > > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._-- +----------------------------------- Jan Goebel j g o e b e l @ d i w . d e DIW Berlin Longitudinal Data and Microanalysis K?nigin-Luise-Str. 5 D-14195 Berlin -- Germany -- phone: 49 30 89789-377 +----------------------------------- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
merge(frame1,frame2) or do a relational database join using one of the SQL interfaces to R. On 6 Mar 2002 at 11:53, Frank Mattes wrote:> Dear R user, > > I'm relative new and need some help / advise from you. I have > organised my data in several frames, mainly because the data came > from different sources. One common variable in all data frames is the > day post transplantation. I would like to combine the data frame to > one big data frame which contains all the data, however no duplicate > rows should occour (only one row for one day) > > Here an example which illustrates what I would like to do: > > Frame 1 > Day Hb wbc > 1 10 4 > 3 11 7 > 5 9 6 > > > Frame 2 > > Day ALT > 1 60 > 2 70 > 4 50 > 5 80 > > Combined > > Day Hb wbc ALT > 1 10 4 60 > 2 NA NA 70 > 3 11 7 NA > 4 NA NA 50 > 5 9 6 80 > > Does anyone know if this can be done, or is it better not to combine > the frames ? > > I appreciate any thoughts or help > > Frank Mattes > Department of Virology > Royal Free and University Medical School > London > -- > > _________________________________________________________ > > > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._