我想要根据特定列,在dataframe1中确定不在dataframe2中的行。我已使用以下代码获取所需信息。
diffId <- anti_join(dat$ID,datwe$ID)
很遗憾,我遇到了一个错误:
Error in UseMethod("anti_join") :
no applicable method for 'anti_join' applied to an object of class "factor"
我检查了数据框中所需列的类,并发现它是factor
。我尝试将该列分离成一个单独的变量,以解决这个问题,但是没有成功!
fac1 <- datwe$ID
fac2 <- dat$ID
diffId <- anti_join(fac2,fac1)
你能分享一下你的想法吗?
谢谢。