In R, I have dataframe 'data_1' and 'data_2', i want to combine them ,the result like "wished_dataframe ".
(just append them into a row bined dataframe: keep the data in the same column if the column name are the same, add new column for unmatched column )
library(tidyverse)
data_1 <- data.frame(a=LETTERS,b=1:26)
data_2 <- data.frame(a=LETTERS,c=letters,b=1:26)
wished_dataframe <- data.frame(a=rep(LETTERS,2),
c=union_all(rep(" ",26),letters),
b=rep(1:26,2))
I use the reduce function,but failed . Anyone can help ? Thanks.
mlist <- list(data1=data_1,
data2=data_2)
reduce(mlist,'join')