# 'I need help combining 2 dataframes (df1 & df2) into a 3rd (mydf). I want the 3rd dataframe to contain 1 row for each row in df1 & df2, and all the columns in both df1 & df2. # Advice is appreciated. Thank you.
df1 <- data.frame(matrix(data=c(7, 99, 12) , nrow=1 , dimnames = list( NULL , c('a' , 'b' , 'd') ) ) ) df2 <- data.frame(matrix(data=c(88, 34, 12, 44, 56) , nrow=1 , dimnames = list( NULL , c('d' , 'b' , 'x' , 'y', 'c') ) ) ) mydf <- matrix(data = c(7, 99, 'na', 12, 'na', 'na', 'na', '34','56','88','12','44') , nrow=2 , byrow = T, dimnames = list( NULL , c('a' , 'b' , 'c' , 'd', 'x' , 'y' ) ) ) df1 df2 mydf > df1 a b d 1 7 99 12 > df2 d b x y c 1 88 34 12 44 56 > mydf a b c d x y [1,] "7" "99" "na" "12" "na" "na" [2,] "na" "34" "56" "88" "12" "44" ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.