Re: [R] rbind with partially overlapping column names

2011-05-16 Thread Jonathan Flowers
quot; wrote: > > > > >> -Original Message- > >> From: r-help-boun...@r-project.org > >> [mailto:r-help-boun...@r-project.org] On Behalf Of Jonathan Flowers > >> Sent: Sunday, May 15, 2011 5:41 PM > >> To: r-help@r-project.org > &

Re: [R] rbind with partially overlapping column names

2011-05-15 Thread Ian Gow
;c")) > merge(df1,df2,all=TRUE) b a c 1 B A c 2 B A c 3 B A c 4 B A c On 5/15/11 11:19 PM, "William Dunlap" wrote: > >> -Original Message- >> From: r-help-boun...@r-project.org >> [mailto:r-help-boun...@r-project.org] On Behalf Of Jonathan Flo

Re: [R] rbind with partially overlapping column names

2011-05-15 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Jonathan Flowers > Sent: Sunday, May 15, 2011 5:41 PM > To: r-help@r-project.org > Subject: [R] rbind with partially overlapping column names > > Hel

Re: [R] rbind with partially overlapping column names

2011-05-15 Thread Dennis Murphy
Hi: Another way, with a little less typing but using the same principle, is df1$c <- df2$a <- NA rbind(df1, df2) Dennis On Sun, May 15, 2011 at 5:50 PM, Ian Gow wrote: > Hi: > > This is a bit of a kluge, but works for your test case: > >> df2[,setdiff(names(df1),names(df2))] <- NA >> df1[,setd

Re: [R] rbind with partially overlapping column names

2011-05-15 Thread Ian Gow
Hi: This is a bit of a kluge, but works for your test case: > df2[,setdiff(names(df1),names(df2))] <- NA > df1[,setdiff(names(df2),names(df1))] <- NA > df3 <- rbind(df1,df2) > df3 a b c 1 A B 2 A B 3 b c 4 b c -Ian On 5/15/11 7:41 PM, "Jonathan Flowers" wrote: >Hello, > >I would like to

[R] rbind with partially overlapping column names

2011-05-15 Thread Jonathan Flowers
Hello, I would like to merge two data frames with partially overlapping column names with an rbind-like operation. For the follow data frames, df1 <- data.frame(a=c("A","A"),b=c("B","B")) df2 <- data.frame(b=c("b","b"),c=c("c","c")) I would like the output frame to be (with NAs where the frames