Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign up`methods` not loaded/working when using lubridate::object notation in Rscript #407
Comments
|
|
|
Its how rscript works and there's little to do with lubridate. Either explicitly attach methods in your script or make a pull request that is adding method in the import of the description file ~ I guess. |
I'm having some trouble executing functions that rely on package methods when being run via Rscript. I already know that methods is not attached via Rscript, but it should be loaded (and usable) by the dependent packages and accessible via their package namespaces, at least I thought so...
Example R script (executed via
Rscript):Output, with my comments and questions mixed below ...
First, here's the startup
sessionInfo():As expected with
Rscript, package methods is not attached, nor loaded.Now, what's surprising to me is that I thought the
lubridate::days(30)call would load methods, since the lubridate package does "Depend" on methods, as verified in lubridate'sDESCRIPTIONfile. Instead, I get the error:But now I'm really confused, because methods does seem to have been loaded, as seen with the next
sessionInfo()call:Just to be sure (about my confusion), let's try calling
lubridate::days(30)again:Same error.
OK, now let's explicitly attach methods and try the
lubridate::days(30)call again:That worked!
What changed by specifically attaching methods?:
methods is not attached (as opposed to loaded-but-not-attached).
I know I could solve all the headaches by simply including
library(methods)atop scripts, but this seems silly, as I thought loading methods would have the same affect to the underlying packages (due to R's package namespacing), without me having to know specifically if any package I use relies on methods or not.Does this seem like an R problem, or possibly a namespace issue with lubridate?