我有一个 data.frame (Data) 和这个 data.frame (Data2) 的一个子集
set.seed(1)
Data <- data.frame(id = seq(1, 10),
Diag1 = sample(c("A123", "B123", "C123"), 10, replace = TRUE),
Diag2 = sample(c("D123", "E123", "F123"), 10, replace = TRUE),
Diag3 = sample(c("G123", "H123", "I123"), 10, replace = TRUE),
Diag4 = sample(c("A123", "B123", "C123"), 10, replace = TRUE),
Diag5 = sample(c("J123", "K123", "L123"), 10, replace = TRUE),
Diag6 = sample(c("M123", "N123", "O123"), 10, replace = TRUE),
Diag7 = sample(c("P123", "Q123", "R123"), 10, replace = TRUE))
Data2 <- Data[1:4,]
如何获得两个 data.frames 的“差异”?我正在寻找在 Data 中但不在 Data2 中的行。
我认为像这样的 Data[!Data2] 应该有效,但它没有。
谢谢!