6

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

Filburt
  • 17,626
  • 12
  • 64
  • 115
Sim
  • 13,147
  • 9
  • 66
  • 95

2 Answers2

8

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>
Julius Vainora
  • 47,421
  • 9
  • 90
  • 102
3

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

mdsumner
  • 29,099
  • 6
  • 83
  • 91