I am having trouble executing functions that rely on package methods when running through Rscript. I already know that the methods are not connected via Rscript, but it must be loaded (and used) by dependent packages and accessible through their package namespaces, at least I thought so ...
R script example (executed via Rscript):
sessionInfo()
tryCatch({
str(lubridate::days(30))
}, error = function(e) {
print(e)
})
sessionInfo()
tryCatch({
str(lubridate::days(30))
}, error = function(e) {
print(e)
})
library(methods)
str(lubridate::days(30))
sessionInfo()
The result, with my comments and questions mixed below ...
First, here's the launch sessionInfo():
# sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Amazon Linux AMI 2015.09
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets base
As expected with Rscript, the package methods are neither connected nor loaded.
, , , lubridate::days(30) , lubridate "" , lubridate DESCRIPTION. :
# tryCatch({
# str(lubridate::days(30))
# }, error = function(e) {
# print(e)
# })
<simpleError in .setupMethodsTables(fdef, initialize = TRUE): trying to get slot "group" from an object of a basic class ("NULL") with no slots>
, , , , sessionInfo():
# sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Amazon Linux AMI 2015.09
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets base
loaded via a namespace (and not attached):
[1] magrittr_1.5 tools_3.2.2 lubridate_1.5.6.9000
[4] stringi_1.0-1 methods_3.2.2 stringr_1.0.0
( ), lubridate::days(30):
# tryCatch({
# str(lubridate::days(30))
# }, error = function(e) {
# print(e)
# })
<simpleError in .setupMethodsTables(fdef, initialize = TRUE): trying to get slot "group" from an object of a basic class ("NULL") with no slots>
.
, lubridate::days(30):
Formal class 'Period' [package "lubridate"] with 6 slots
..@ .Data : num 0
..@ year : num 0
..@ month : num 0
..@ day : num 30
..@ hour : num 0
..@ minute: num 0
!
, ?:
# sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Amazon Linux AMI 2015.09
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] methods stats graphics grDevices utils datasets base
loaded via a namespace (and not attached):
[1] magrittr_1.5 tools_3.2.2 lubridate_1.5.6.9000
[4] stringi_1.0-1 stringr_1.0.0
( , ).
, , library(methods) , , , (- R package namespacing), , - , , .
R , , (, ) lubridate?