Good afternoon!
I'm a system administrator at a university, and I am responsible for setting up the images for a computer lab. R is part of the default image, and for the longest time we only had a single log-in for all lab users, allowing us to set the default directory once and then image it across multiple systems. This has changed, and we're now having all users log on with a personalized log-in. That brings me to a problem I'm having with R, and why I'm turning to you.
You see, as most of you may be aware, when R is run for the first time, a dialog box opens up that prompts for a location to save packages and the like. Hit 'OK' and it's the user file, but hit anything else and it's wherever you put it. The problem is, we've locked down the systems rather tightly, and access to anything more than the user's individual directory is not something we like to do.
The question I have is this - is there a way to force R, on first run, via hands-free script or just a setting somewhere, to default to the user's directory on the system for package storage? This would prevent me from having to give All Users access to read and write to the R directory, and would have fewer possibilities of screwing up since they wouldn't actually have a choice to change it. If I have to continue giving permissions in that folder, I can, but I'd rather not.
Thanks!
The way to change a package library location is to manually set it on a startup file i.e. folder) or project-level (located at the current working directory). ✏ For more information about R startup files, you can read the following support article.
R uses a single package library for each installed version of R on your machine. Fortunately it is easy to modify the path where R installs your packages. To do this, you simply call the function . libPaths() and specify the library location.
R packages are a collection of R functions, complied code and sample data. They are stored under a directory called "library" in the R environment. By default, R installs a set of packages during installation.
Edit your .Renviron file to set the default path:
# .Renviron file
R_LIBS = '~/.R/library'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With