dfa
date league a b home draw away
1 2019-12-22 17:00 BL Paderborn Eintracht Frankfurt 3.48 4.06 2.01
2 2019-12-22 14:30 BL Fortuna Düsseldorf Unión Berlín 2.80 3.31 2.67
dfb
c d home1 draw1 away1
1 TSG Hoffenheim Eintracht Frankfurt 2.37 3.60 2.75
2 Schalke 04 Borussia Mönchengladbach 2.40 3.50 2.75
3 RB Leipzig Unión Berlín 1.25 6.00 10.00
4 Paderborn Eintracht Frankfurt 3.40 4.00 2.00
5 Paderborn Bayer Leverkusen 5.25 4.50 1.53
6 Mainz SC Friburgo 2.30 3.30 3.10
7 Hertha Berlín Bayern de Múnich 10.00 6.00 1.25
8 Fortuna Düsseldorf Unión Berlín 2.75 3.25 2.62
9 Fortuna Düsseldorf Werder Bremen 2.50 3.50 2.62
10 Colonia Wolfsburgo 2.70 3.40 2.50
11 Augsburgo Borussia Dortmund 5.00 4.33 1.57
I wish to combine dfa with dfb and get the below result.
data
date a b home draw away c d home1 draw1 away1
1 2019-12-22 14:30 Fortuna Düsseldorf Unión Berlín 2.80 3.31 2.67 Fortuna Düsseldorf Unión Berlín 2.75 3.25 2.62
2 2019-12-22 17:00 Paderborn Eintracht Frankfurt 3.48 4.06 2.01 Paderborn Eintracht Frankfurt 3.40 4.00 2.00
I tried with this below but can't figure out how to arrange them with differing nr of rows. I'm looking for a solution that works no matter which df has more rows. Any input much appreciated.
myd <- merge(dfa, dfb, by = "row.names", all = TRUE)
myd
Row.names date league a b home draw away c d home1 draw1 away1
1 1 2019-12-22 17:00 BL Paderborn Eintracht Frankfurt 3.48 4.06 2.01 TSG Hoffenheim Eintracht Frankfurt 2.37 3.60 2.75
2 10 <NA> <NA> <NA> <NA> NA NA NA Colonia Wolfsburgo 2.70 3.40 2.50
3 11 <NA> <NA> <NA> <NA> NA NA NA Augsburgo Borussia Dortmund 5.00 4.33 1.57
4 2 2019-12-22 14:30 BL Fortuna Düsseldorf Unión Berlín 2.80 3.31 2.67 Schalke 04 Borussia Mönchengladbach 2.40 3.50 2.75
5 3 <NA> <NA> <NA> <NA> NA NA NA RB Leipzig Unión Berlín 1.25 6.00 10.00
6 4 <NA> <NA> <NA> <NA> NA NA NA Paderborn Eintracht Frankfurt 3.40 4.00 2.00
7 5 <NA> <NA> <NA> <NA> NA NA NA Paderborn Bayer Leverkusen 5.25 4.50 1.53
8 6 <NA> <NA> <NA> <NA> NA NA NA Mainz SC Friburgo 2.30 3.30 3.10
9 7 <NA> <NA> <NA> <NA> NA NA NA Hertha Berlín Bayern de Múnich 10.00 6.00 1.25
10 8 <NA> <NA> <NA> <NA> NA NA NA Fortuna Düsseldorf Unión Berlín 2.75 3.25 2.62
11 9 <NA> <NA> <NA> <NA> NA NA NA Fortuna Düsseldorf Werder Bremen 2.50 3.50 2.62