Repository navigation
Conflicting date time accessors with lubridate #1135
Description
Activity
Loading
data.tableand thenlubridateor using::operator should resolve this? Deprecating it for name clashes seems extreme.Deprecating it for name clashes seems extreme.
The main proposal was to move IDate into a specialized package. It would make data.table a cleaner package.
Reacted by aryoda+1
@vspinu @zippeurfou
Namespace collision can always happen, what if the next version of other popular package creates a function with overlapping name?- The best way to handle that for production code is to use
importFrominNAMESPACEfile in your package. - The most convenient way to handle that for interactive use is to load packages in required order, eventually use
::operator.
You may be also interested in How does R handle overlapping object names?.
Reacted by aryoda- The best way to handle that for production code is to use
Note:
Some unit tests of
data.tablefail if you do loadlubridateafterdata.table.IMHO You shouldn't load
lubridateif you want to run the
unit tests to verify the correct installation ofdata.table!library(lubridate) library(data.table) test.data.table() # runs without errorsIf you reset the R session and load
data.tablefirst you will get some unit test errorslibrary(data.table) library(lubridate) test.data.table() # runs with unit test errorssaying e. g.
Running test id 546 Test 546 ran without errors but failed check that x equals y:
Thanks @aryoda. More to do then, including adding tests to
test.data.table(with.other.packages=TRUE).Reacted by aryodaIt make sense to attach all exported data.table functions at the beginning of test.data.table(), or eventually detect if exported data.table got masked.
- added a commit that references this issue
on Jan 4, 2022 library(data.table) library(lubridate) test.data.table()
Currently passes. Closing.
A pretty long list of date-time accessors in
data.tableconflicts withlubridate:A lot of people, including myself, use both
data.tableandlubridateroutinely. So this overlap is rather an inconvenience. There was even a recent bug report tolubridateas a result of the name collision.Given that
data.tableis not dedicated package for working with date-times I wonder if date-time functionality could be split into a separate package or date-time accessors deprecated.The definitions of these functions in data.table are very basic. In lubridate these are all generics with methods for a variety of classes. Setters are also provided. The default method is the same as it is defined in
data.table.