我在dplyr中有两个包含数据的表,第三个表指定了这些表中各行之间的1对1映射。我想从两个数据表中只记录1对1映射表中的条目,这样我就可以将两个数据表中的结果直接相互比较(它们的顺序不同,有些行也是如此)在其他数据表中没有相应的条目)。我尝试在我的数据表和映射表之间使用inner_joins执行此操作,但似乎每次都缺少一行,特别是第一行。它似乎在连接中将第二个非“by”值向上移动了一行。这里有一些应该有用的输出:
>PA14ortho #the 1-to-1 mapping table
Source: local data frame [5,366 x 2]
PAO1.id PA14.id
1 PA0001 PA14_00010
2 PA0002 PA14_00020
3 PA0003 PA14_00030
4 PA0004 PA14_00050
.. ... ...
> select(PA14.3rep.res, PA14.id) #the "label" row in my first data table
Source: local data frame [5,977 x 1]
PA14.id
1 PA14_00010
2 PA14_00020
3 PA14_00030
4 PA14_00050
.. ...
> inner_join(PA14.3rep.res, PA14ortho, by="PA14.id") %>% select(PA14.id, PAO1.id) #the results of the inner join, note how there's one less record and that PAO1.id has shifted up one
Source: local data frame [5,365 x 2]
PA14.id PAO1.id
1 PA14_00010 PA0002
2 PA14_00020 PA0003
3 PA14_00030 PA0004
4 PA14_00050 PA0005
.. ... ...
> select(PAO1.3rep.res, PAO1.id) #the second data table
Source: local data frame [5,606 x 1]
PAO1.id
1 PA0001
2 PA0002
3 PA0003
4 PA0004
.. ...
> inner_join(PAO1.3rep.res, PA14ortho, by="PAO1.id") %>% select(PAO1.id, PA14.id) #the same thing happens - the non-"by" row is shifted up one
Source: local data frame [5,365 x 2]
PAO1.id PA14.id
1 PA0001 PA14_00020
2 PA0002 PA14_00030
3 PA0003 PA14_00050
4 PA0004 PA14_00060
.. ... ...
感谢您的帮助!