[Solved] Merge data frame based on column names in r


Working Azure ML – This was the best option I found to automate this merge.

df <- maml.mapInputPort(1)
df2 <- maml.mapInputPort(2) 

if (length(df2.toAdd <- setdiff (names(df), names(df2))))
df2[, c(df2.toAdd) := NA]

if (length(df.toAdd <- setdiff (names(df2), names(df))))
df[, c(df.toAdd) := NA]

df3 <- rbind(df, df2, use.names=TRUE)


maml.mapOutputPort("df3");

0

solved Merge data frame based on column names in r