0

I am having an issue changing my default library in R. I previously had a storage space problem on my university laptop and IT amended my user drives which left my previous Rlibrary in limbo somewhere on the previous drive. I have uninstalled and re-installed R a few times just to be sure, but it remembers my previous library location when I re-install it. And subsequently R struggles to see the packages I need to run my models. I have subsequently tried (unsuccessfully) to implement the steps in this previous post: Where does R store packages? The main problem I encounter is when I attempt to edit the R.profile.site file using VIM it says E12: Rprofile.site: Can't open file for writing. I have also tried the same edit in Notepad ++ which doesn't work either. I am no computer programmer so perhaps there is a step I am missing here?

What I really want is one repository for my library. I would be happy to simply remove [1] below as this is the now defunct drive. My current library paths are:

.libPaths() [1] "\\studenthome.qut.edu.au/group05$/n2559005/Documents/R/win-library/3.1" [2] "C:/Program Files/R/R-3.1.2/library"

1 Answer 1

1

The issue your're running into is that windows has special permissions for subdirectories of C:/Program Files/. You may be able to edit the site profile by opening it in R using the 'Open Script' option in the the File menu.

Incidentally, you can implement the same solution by creating a .Rprofile file here:

path.expand('~/.Rprofile')

and placing your call to .libPaths( "/my/favorite/directory" ) in that file. In addition, you can define a function like

.First <- function(){
    if( interactive() ){
        cat("\nWelcome",Sys.info()['login'],"at", date(), "\n")
        if('fortunes' %in% utils::installed.packages()[,1] )
            print(fortunes::fortune())
    }
}

in your .Rprofile file, and if you get your fortune at startup, you know that the correct file was sourced at startup. See ?Startup (specifically the third paragraph) for details.

2
  • I have run into the very issue you mention of not being able to edit the file either using VIM or R. So I tried the second solution, and it worked but only for my active R session, once R was shut-down and re-opened the problem persisted. Any further ideas/advice would be greatly appreciated.
    – pumicegirl
    Commented Feb 23, 2015 at 3:26
  • If you the second solution didn't work, it's likely because path.expand('~/.Rprofile') is different for your subsequent R sessions, for some reason. I recommend checking path.expand('~/.Rprofile') in the subsequent session, and checking that it points to the file you created.
    – Jthorpe
    Commented Feb 23, 2015 at 3:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.