This question already has an answer here:
这个问题在这里已有答案:
- How to compare functions? 3 answers
如何比较功能? 3个答案
Is there a way to determine if the text of two different functions is identical?
有没有办法确定两个不同功能的文本是否相同?
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
2 个解决方案
#1
10
I think this is a good method. It works for many different objects:
我认为这是一个很好的方法。它适用于许多不同的对象:
all.equal(x,y)
[1] TRUE
#2
#1
10
I think this is a good method. It works for many different objects:
我认为这是一个很好的方法。它适用于许多不同的对象:
all.equal(x,y)
[1] TRUE