function naming conflicts

非 Y 不嫁゛ 提交于 2019-11-30 04:56:31

问题


What are some good patterns for development with packages that define the same function? In my case, lubridate and data.table both define wday.


回答1:


You can use ::, it helps to specify which package to use:

lubridate::wday
function (x, label = FALSE, abbr = TRUE) 
UseMethod("wday")
<environment: namespace:lubridate>

data.table::wday
function (x) 
as.POSIXlt(x)$wday + 1L
<environment: namespace:data.table>



回答2:


Use the namespace mechanism for your packages. See the R Extensions manual.



来源:https://stackoverflow.com/questions/11490359/function-naming-conflicts

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