R中的匹配值

R中的匹配值,r,dataframe,dplyr,R,Dataframe,Dplyr,喂,我有数据集 mydat=structure(list(x1 = structure(c(2L, 3L, 4L, 5L, 1L), .Label = c("", "a", "b", "c", "d"), class = "factor"), x2 = structure(1:5, .Label = c("a", "b", "c", "d", "e"), class = "factor")), .Names = c("x1", "x2" ), class = "data.frame", ro

喂,我有数据集

mydat=structure(list(x1 = structure(c(2L, 3L, 4L, 5L, 1L), .Label = c("", 
"a", "b", "c", "d"), class = "factor"), x2 = structure(1:5, .Label = c("a", 
"b", "c", "d", "e"), class = "factor")), .Names = c("x1", "x2"
), class = "data.frame", row.names = c(NA, -5L))

x1 has values a,b,c,d
x2 has values a,b,c,d,e
如何显示x2变量中存在的值,而x1中没有? 在我们的例子中,这是
e
-值

作为我想要的输出

    Value
1   e
如果这个问题重复,请告诉我,我会删除它。

我们可以试试

setdiff(mydat$x2,mydat$x1)
[1] "e"
带有(mydat,x2[!(x2%位于%x1)])