试试这个功能
all.equal(df[1,],df[2,])
[1] "Attributes: < Component 2: Mean relative difference: 1 >"
(一般比较因素可能会产生“意外”的结果......)在这种情况下identity
,尝试匹配所有内容,发现不同row.names
,您可以从以下内容中看到dput
:
> dput(df[1,])
structure(list(x = structure(1L, .Label = c("x", "y"), class = "factor"),
y = structure(2L, .Label = c("x", "y"), class = "factor")), .Names = c("x",
"y"), row.names = 1L, class = "data.frame")
> dput(df[2,])
structure(list(x = structure(1L, .Label = c("x", "y"), class = "factor"),
y = structure(2L, .Label = c("x", "y"), class = "factor")), .Names = c("x",
"y"), row.names = 2L, class = "data.frame")
在这个例子中,一个简单的==
作品:
> df[1,]==df[2,]
x y
1 TRUE TRUE