![](/img/trans.png)
[英]How do I Identify by row id the values in a data frame column not in another data frame column?
[英]How do I move a row in one data frame to a column in another data frame?
我试图在一个数据框中移动一行以将其添加到另一个数据框中以创建新列。 我有d1帧:
x y
1 VBR 33333
2 VEA 33333
3 VTV 33333
和框架sh:
VBR VEA VTV
2014-02-04 360.9457 875.3501 469.1532
sh最初是作为Zoo类开始的,但是我尝试将两个框架都转换为矩阵或数据框架并使用merge,但似乎没有任何效果。
当我尝试合并(d1,共享)时,我得到:
x y VBR VEA VTV
1 VBR 33333 360.9457 875.3501 469.1532
2 VEA 33333 360.9457 875.3501 469.1532
3 VTV 33333 360.9457 875.3501 469.1532
我想要的是:
1 VBR 33333 360.9457
2 VEA 33333 875.3501
3 VTV 33333 469.1532
我该怎么做呢?
尝试:
cbind(d1, t(sh))
这应该为您工作。
cbind()
按列组合data.frames
, t()
将sh
从1行3列转置为3行1列。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.