Suppose I have two datasets:
d1:
A B C
1 0 2 4
2 1 2 3
3 2 1 0
d2:
D E
1 3 8
2 1 5
3 2 7
I want to have a data set that is the combination of the two which should look:
A B C D E
1 0 2 4 3 8
2 1 2 3 1 5
3 2 1 0 2 7
I've tried merge but it cross joins them making 3*3.
We can use cbind
do.call(cbind, list(d1, d2))
Or using dplyr
library(dplyr)
bind_cols(d1, d2)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.