【发布时间】:2015-12-03 04:35:43
【问题描述】:
我正在尝试同时将 all.equal 应用于多个对象。
我的初始代码如下:
all.equal(1,1.01, tolerance = 1e-1)
这是一种方法:
objs <- mget(c(1,1.01,1.02))
outer(objs, objs, Vectorize(all.equal))
但我不知道如何包含容差声明。
有什么想法吗?
【问题讨论】:
-
运行
mget行时出现错误。我不确定您要做什么,但也许是这样?:sapply(x, FUN=function(x) { all.equal(1,x,tolerance=1e-1)})wherex = c(1,1.01,1.02) -
也许这个 -->
outer(objs, objs, FUN=function(a,b,toler){ mapply(function(x,y){all.equal(x,y,toler)},a,b) },toler=1e-1)
标签: r