说,我有数据集
- env:
- name: DB_ADDR
value: postgres
如何显示x2变量中存在的值,但x1中没有变量?
在我们的例子中,这是- env:
- name: DB_ADDR
value: postgres-keycloak
值
我想要的输出
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
如果该问题重复,请告诉我,我将其删除。
答案 0 :(得分:1)
我们可以尝试
setdiff(mydat$x2,mydat$x1)
[1] "e"