0

I have two very large data frames. One has many named columns, and the second has a subset of those named columns. I would like to add the rows of the second data frame to the first data frame, without having to add NA filled columns to the second data frame (as there are many columns not in the second data frame that are in the first data frame).

Here is an example of what I want:

#make two data frames, one is a subset of the columns of the other
df1 <- data.frame(a = c(1,2,3), b = c(4,5,6), c = c(7,8,9))
df2 <- data.frame(b =  c(7,33,6), c = c(100,100,1000))

Goal

df3 <- data.frame(a = c(1,2,3,NA,NA,NA), b = c(4,5,6,7,33,6), c = c(7,8,9,100,100,1000))
df3
   a  b    c
1  1  4    7
2  2  5    8
3  3  6    9
4 NA  7  100
5 NA 33  100
6 NA  6 1000
colin
  • 2,606
  • 4
  • 27
  • 57

0 Answers0