I have 2 data frames D1 and D2. dim(D1) = 6096 x 2 dim(D2) = 6100 x 5 I would like to connect D1 and D2 such that we have both the two columns of D2 followed by both the 4 columns of D2 on the right. And, 4 rows of first two columns (D1) have NA's or Null or 0 values. I'm looking for a function. Many questions on stacks overflow are where both data frames are added to each other either by rows or column. I don't want to add their values.
Imagine dataframes df1 and df2 and the output is dfinal.
df1 = data.frame(rep(c(1,3,5,7), 2))
df2 = data.frame(rep(c(2,4,6,8), 2))
df1 = cbind(df1,df2)
colnames(df1) = c("C1","C2")
df3 = data.frame(rep(c("1","b","c"), 2))
df4 = data.frame(rep(c("d","3","f"), 2))
df5 = data.frame(rep(c("g","h","2"), 2))
df2 = cbind(df3,df4,df5)
colnames(df2) = c("C3","C4","C5")
df2 = rbind(df2, NA)
df2 = rbind(df2, NA)
dfinal = cbind(df1,df2)