组合具有不同长度和顺序的列

时间:2018-03-30 08:24:53

标签: r dataframe matrix

我的数据是:

a
     [,1]
[1,]    1
[2,]    2
[3,]    3
[4,]    4
[5,]    5

和:

b
     [,1]
[1,]    7
[2,]    8
[3,]    9
[4,]   10
[5,]   11
[6,]   12

我们怎样才能得到这个? :

enter image description here

1 个答案:

答案 0 :(得分:0)

一个选项是cbind.fill

setNames(rowr::cbind.fill(a, b, fill = NA), c("a", "b"))
#   a  b
#1  1  7
#2  2  8
#3  3  9
#4  4 10
#5  5 11
#6 NA 12
相关问题