function naming conflicts

后端 未结 2 630
一向
一向 2021-01-05 18:06

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

相关标签:
2条回答
  • 2021-01-05 18:13

    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>
    
    0 讨论(0)
  • 2021-01-05 18:34

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

    0 讨论(0)
提交回复
热议问题