Apologies if someone has asked this before. I've tried Googling and Googling, but no one seems to have reported quite this. I'm trying to add a path to my .libPaths
, but .libPaths(new=blah)
doesn't seem to alter anything. Here is my code:
packagedir = paste0(getwd(),'/extraRPackages/')
newLibPaths = c(packagedir,.libPaths())
print(newLibPaths)
.libPaths(newLibPaths)
print(.libPaths())
...here is the output from the first print (what I'm passing into .libPaths
):
[1] "C:/Users/GCW/Dropbox/Mash share/Phil/R/mashdb/database/extraRPackages/"
[2] "C:/Users/GCW/Documents/R/win-library/3.3"
[3] "C:/Program Files/R/R-3.3.1/library"
... and the second print:
[1] "C:/Users/GCW/Documents/R/win-library/3.3" "C:/Program Files/R/R-3.3.1/library"
Why might my call to .libPaths(new=blah) do absolutely nothing?? I'm stumped! I've tried it in RStudio and RPortable, but both give me the same output... Any help v much appreciated...
(I know from reading other answers that there are "proper" ways to change the paths permanently, but this is something I want to be able to do dynamically in a rather unusual setup, and if .libPaths just did what I thought it would, I'd be done...)
EDIT: It was suggested that this might be a duplicate of this question Changing R default library path using .libPaths in Rprofile.site fails to work -- but I don't think it is. I read this question before posting my own -- but in this question, it says at the end that "if I start RStudio the .libPaths() command seems to work as it is supposed to" -- but it is precisely in RStudio that the command doesn't do anything for me (and this is where I want to use it, not in the RProfile.site file and not in any permanent way)....