do.call() doesn't like base function “c” with a list

 ̄綄美尐妖づ 提交于 2019-12-06 00:30:20

I will answer "stealing" my answer from this comment by Nick Kennedy:

It might be better to put the c in double quotes.

If the user has a non-function named c in the global environment, do.call(c, dates) will fail with the error "Error in do.call(c, list(1:3)) : 'what' must be a character string or a function".

Clearly it may not be best practice to define c, but it's quite common for people to do a <- 1; b <- 2; c <- 3.

For most purposes, R still works fine in this scenario; c(1, 2) will still work, but do.call(c, x) won't.

Of course if the user has redefined c to be a function (e.g. c <- sum), then do.call will use the redefined function.

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