R on Remote Server
October 10, 2021•230 words
This is a brief documentation of how to set up an R environment in Windows in a remote workspace for an end user that will not have internet access.
We will assume that we can access the server workspace at G:\user_id\
, that the user can access it from H:\
, and that the directory structure looks like this:
├── applications <- Applications added by the administrator
│ └── r
│ ├── libraries <- R packages
│ ├── R <- Base R files
│ └── RStudio <- Optional R Studio
│
└── user <- The users files and folders
Base R
Download the R installer from here:
https://cran.r-project.org/bin/windows/base/release.htm
Start the installer and choose the installation directory to be in the users applications directory:
G:\user_id\applications\r\R
RStudio
Download the RStudio zip archive from:
https://www.rstudio.com/products/rstudio/download/#download
Extract the contents of the archive to:
G:\user_id\applications\r\RStudio
Install Packages
To install packages to the libraries
directory, start by specifying the install path and then install the packages using this path:
lib_path = "G:/user_id/applications/R/libraries"
install.packages("package_name", lib=lib_path)
Use Packages (for the end user)
For the user to be able to load the packages, they need to set the libpath
in R to the correct folder in every session/script before loading the packages:
.libPaths("H:/applications/R/libraries")
library(package_name)
Another possible solution is to set the libpath
in the .Rprofile
file in the
users home directory.