Is there a work around for slow performance of do.call(cbind.xts,…) in R 2.15.2?

ぃ、小莉子 提交于 2019-11-30 19:55:50

One work-around is to set quote=TRUE in do.call.

R> system.time(cb <- cbind.xts(d1,d2))
   user  system elapsed 
  0.004   0.000   0.004 
R> system.time(dc <- do.call(cbind.xts, list(d1,d2), quote=TRUE))
   user  system elapsed 
  0.000   0.004   0.004 
R> identical(cb,dc)
[1] TRUE

The slowness is caused by do.call evaluating the arguments before evaluating the function call by default, which causes the call to be much larger. For example, compare these two calls:

call("cbind", d1, d2)                # huge
call("cbind", quote(d1), quote(d2))  # dainty
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!