Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有两个 daframe(A,B),它们都包含完全相同的列。
A<-data.frame(factor=c("A","B","C"),value=c(1,2,3)) B<-data.frame(factor=c("A","B","C","D","E"),value=c(7,8,9,4,5))
最后,我想要一个子集,B其中仅包含A$factor(A,B,C) 的级别和相应的值。关于如何做到这一点的任何想法?我查看了该merge()功能,但无法使其正常工作。
B
A$factor
merge()
另一种解决方案可能是:
B[B$factor%in%A$factor,]