我想测试ggplot生成的两个图是否相同.一种选择是all.equal在情节对象上使用,但我宁愿进行更难的测试以确保它们是相同的,这似乎是identical()我提供的东西.
但是,当我测试两个使用相同 data和相同 创建的绘图对象时aes,我发现它们all.equal()识别它们是相同的,而对象没有通过identical测试.我不确定为什么,我想要了解更多.
基本示例:
graph <- ggplot2::ggplot(data = iris, aes(x = Species, y = Sepal.Length))
graph2 <- ggplot2::ggplot(data = iris, aes(x = Species, y = Sepal.Length))
all.equal(graph, graph2)
# [1] TRUE
identical(graph, graph2)
# [1] FALSE
Run Code Online (Sandbox Code Playgroud)