I need to set the library path in R for a single use (i.e. I do not want and can't set it in Rprofile.site
and can't put the additional packages into the default library).
I tried to append to and to overwrite the library path with .libPaths()
but neither worked; the path remained unchanged. See my attempts below.
Since I have seen examples that effectively are the same as my attempts, I have a feeling that it might be an authorisation issue: I simply have no rights to change the path.
I have searched stackoverflow, but the questions/solutions do not match my problem. Any suggestions? And no, turning it off and on again would not help.
My environment is Mac (High Sierra), R 3.4.3, RStudio 1.1.423, R newbie user (not root
).
Thanks!
Original path
> .libPaths()
[1] "/Library/Frameworks/R.framework/Versions/3.4/Resources/library"
> .Library
[1] "/Library/Frameworks/R.framework/Resources/library"
Trying to append
> .libPaths( c( .libPaths(), "<some_other_valid_path>") )
> .libPaths()
[1] "/Library/Frameworks/R.framework/Versions/3.4/Resources/library"
> .Library
[1] "/Library/Frameworks/R.framework/Resources/library"
Trying to overwrite
> .libPaths("<some_other_valid_path>")
> .libPaths()
[1] "/Library/Frameworks/R.framework/Versions/3.4/Resources/library"
> .Library
[1] "/Library/Frameworks/R.framework/Resources/library"
"<some_other_valid_path>"
? Are you, for instance, leaving on or removing any trailing"/
" in the specification of the path?/
. See, my answer below for explanation of the cause and solution.