从这两个数据帧开始:
data <- data.frame("Run_ID" = c(1,2,3), "Sample" = c("A", "B", "C"), "Value" = c(1,2,3))
metadata <- data.frame("Run_ID" = c(1,3), "Sample" = c("A","C"))
我想对子集进行子集data
化,使其仅包含来自Run_ID
+对的值,这些值Sample
也存在于metadata
. 输出应包含与 相同的列data
。
预期输出:
Run_ID Sample Value
1 A 1
3 C 3
根据文档,它似乎semi_join()
应该是解决方案,但我无法根据这两个变量找出连接。
>semi_join(data, metadata, by = c("Run_ID", "Sample"))
[1] Run_ID Sample Value
<0 rows> (or 0-length row.names)
任何建议都非常感谢!