Is it possible to set the default location for R packets instead of giving the user a choice?

Good afternoon!

I am a system administrator at the university and I am responsible for setting up the images for the computer lab. R is part of the default image, and for the longest time we had only one login for all laboratory users, which allowed us to set the default directory once and then display it on several systems. This has changed, and now we have all users logged in with a personalized login. This leads me to a problem that I ran into R and why I am contacting you.

As you can see, most of you know when R starts for the first time, a dialog box appears asking for a location to save packages, etc. Hit "OK", and this is the user file, but hit something else, and where you put it. The problem is that we locked the systems rather tightly, and access to anything other than a separate user directory is not something we like.

The question I have is this: is there a way to force R when I first run it through a hands-free script, or just set the default value for the user directory on the system to store packages? This would prevent me from giving all users read and write access to the R directory, and it would have less ability to screw in, since they would actually have no choice to change it. If I need to continue granting permissions in this folder, I can, but I would prefer not to.

Thanks!

+6
source share
3 answers

I can't check it right now, but I believe that you could add something like Sys.setenv(R_LIBS_USER=path.expand('~\R\library')) to the Rprofile.site file found in the R directory etc.

+1
source

Modify the .Renviron file to set the default path:

 # .Renviron file R_LIBS = '~/.R/library' 
+1
source

'... the default for the user directory on the system for storing packages ...'

another way, especially if you want different settings for employees / students to use group policy to set an environment variable for selected computers / users at login.

eg. equivalent...

 SETX "R_LIBS" "\\fileserver2/department_shared/public/r/packages" 

you can easily check if this works by running R and trying

 Sys.getenv("R_LIBS") 

also, this command can then show you which packages are installed:

 rownames(installed.packages()) 
0
source

All Articles