[R] merging dataframes

2005-11-03 Thread Gavin Simpson
Dear List, I often have to merge two or more data frames containing unique row names but with some columns (names) common to the two data frames and some columns not common. This toy example will explain the kind of setup I am talking about: mat1 <- as.data.frame(matrix(rnorm(20), nrow = 5)) mat2

[R] merging dataframes

2005-11-03 Thread ManuelPerera-Chang
Hi, what about padding both datasets with dummy missing records ... and then play with cbind and rbind ... like e.g. > species5<-c(NA,NA,NA,NA) > modmat2<-cbind(mat2,species1,species5) and then similarly with mat1 ... e.g. species2<-c(NA,NA,NA,NA,NA) > modmad1<-cbind(mat1,species2,species

Re: [R] merging dataframes

2005-11-03 Thread Roger Bivand
On Thu, 3 Nov 2005, Gavin Simpson wrote: > Dear List, > > I often have to merge two or more data frames containing unique row > names but with some columns (names) common to the two data frames and > some columns not common. This toy example will explain the kind of setup > I am talking about: >

Re: [R] merging dataframes

2005-11-03 Thread Dimitris Rizopoulos
"R-help" Sent: Thursday, November 03, 2005 2:08 PM Subject: [R] merging dataframes > Dear List, > > I often have to merge two or more data frames containing unique row > names but with some columns (names) common to the two data frames > and > some columns not common. This

Re: [R] merging dataframes

2005-11-03 Thread Liaw, Andy
The `Value' section of ?merge does say that `... in all cases the result has no special row names', so you're left to handle that on your own. One possibility is to use result <- merge(mat1, mat2, all=TRUE, sort=FALSE) so that the sorting is not done, then you can just do rownames(result) <

Re: [R] merging dataframes

2005-11-03 Thread Gavin Simpson
On Thu, 2005-11-03 at 08:33 -0500, Liaw, Andy wrote: > The `Value' section of ?merge does say that `... in all cases the result has > no special row names', so you're left to handle that on your own. One > possibility is to use > > result <- merge(mat1, mat2, all=TRUE, sort=FALSE) > > so that

[R] merging dataframes with diffent rownumbers

2007-06-18 Thread Thomas Hoffmann
Dear R-Helpers, I have following problem: I do have two data frames dat1 and dat2 with a commen column BNUM (long integer). dat1 has a larger number of BNUM than dat2 and different rows of dat2 have equal BNUM. The numbers of rows in dat1 and dat2 is not equal. I applied the tapply-function

Re: [R] merging dataframes with diffent rownumbers

2007-06-18 Thread Michael Dewey
At 09:09 18/06/2007, Thomas Hoffmann wrote: >Dear R-Helpers, > >I have following problem: > >I do have two data frames dat1 and dat2 with a commen column BNUM >(long integer). dat1 has a larger number of BNUM than dat2 and >different rows of dat2 have equal BNUM. The numbers of rows in dat1 >and

Re: [R] merging dataframes with diffent rownumbers

2007-06-18 Thread Petr Klasterecky
No easy to understand what exactly you mean, but try ?merge ?cbind ?rbind Petr Thomas Hoffmann napsal(a): > Dear R-Helpers, > > I have following problem: > > I do have two data frames dat1 and dat2 with a commen column BNUM (long > integer). dat1 has a larger number of BNUM than dat2 and diffe