我想加入两个小词,但不希望采用标准方式。我的可复制示例如下。我有以下小标题:
> tb1
# A tibble: 2 x 3
# Groups: symbol [1]
symbol open tarima
<chr> <dbl> <dbl>
1 A 25.3 59.5
2 A 27.1 61.7
> tb2
# A tibble: 4 x 2
# Groups: symbol [2]
symbol open
<chr> <dbl>
1 B 60.8
2 B 60.3
3 CD 32.4
4 CD 33.6
我想获得输出:
# A tibble: 6 x 3
# Groups: symbol [3]
symbol open tarima
<chr> <dbl> <dbl>
1 A 25.3 59.5
2 A 27.1 61.7
3 B 60.8 59.5
4 B 60.3 61.7
5 CD 32.4 59.5
6 CD 33.6 61.7
答案 0 :(得分:2)
我们可以先rbind
个匹配的列,然后再添加另一个以回收:
cbind(rbind(tb1[-3], tb2), tb1["tarima"])
# symbol open tarima
# 1 A 25.3 59.5
# 2 A 27.1 61.7
# 11 B 60.8 59.5
# 21 B 60.3 61.7
# 3 CD 32.4 59.5
# 4 CD 33.6 61.7