标签: r
有没有办法确定两个不同功能的文本是否相同?
x <- function(x) print(x + 2) y <- function(x) print(x + 2) identical(x, y) [1] FALSE identical(mget("x"), mget("y")) [1] FALSE identical(unname(mget("x")), unname(mget("y"))) [1] FALSE
答案 0 :(得分:10)
我认为这是一个很好的方法。它适用于许多不同的对象:
all.equal(x,y) [1] TRUE
答案 1 :(得分:3)
使用library(diffobj) x <- function(x) print(x + 2) y <- function(x) print(x + 2) diffPrint(target = x, current = y) 包:
library(diffobj) x <- function(x) print(x + 2) y <- function(x) print(x + 2) diffPrint(target = x, current = y)
any()
将其包含在any(diffPrint(target = x, current = y)) # FALSE 中将给出TRUE / FALSE:
any(diffPrint(target = x, current = y)) # FALSE
{{1}}