Jun 7, 2017

Multiple RStudio instances HOW-TO

Multiple RStudio instances HOW-TO
Brief guide to run multiple independent RStudio instances on the same machine. Sometimes it could be useful to run several RStudio scripts simultaneously. The standard RStudio 0.99.902 on Windows 10 machine do not allow such functionality, as the single R en...
http://vshalisko.blogspot.com/2017/06/multiple-rstudio-instances-how-to.html Читать дальше......

Multiple RStudio instances HOW-TO

Brief guide to run multiple independent RStudio instances on the same machine.

Sometimes it could be useful to run several RStudio scripts simultaneously. The standard RStudio 0.99.902 on Windows 10 machine do not allow such functionality, as the single R environment is linked to all instances of RStudio you can run. The solution I found is to install RStudio server on virtual machine (container) and use several copies of such container to be able to run several independent analysis.

The solution include several steps:

1) You should have Docker (www.docker.com) container manager installed on your Windows (or any other OS) system. In my case Docker works in combination with VirtualBox (www.virtualbox.org).

2) Install rocker/rstudio container from hub.docker.com/r/rocker/rstudio/, the manual Using the RStudio image could be rather useful.

pull rocker/rstudio

3) Get the list of Docker machines and its IPs:

docker-machine ls
docker-machine ip default

4) Run the initial instance of rocker/rstudio

docker run -d -p 8787:8787 rocker/rstudio

5) Connect with the RStudio server from browser, using the IP and port number from steps 3 & 4, something like:

http://192.168.99.100:8787/

6) Use login rstudio and password rstudio to open session

7) Install necessary R packages using RStudio interface. In my case the set of packages include: foreign, maps, sp, maptools, raster, dismo, rgeos, mgcv, fields, gstat, geoR, rgdal.

8) Some packages cannot be successfully installed without previous installation of external components. In case of geoR the required package is tcltk ver. 8.5 and related packages, in case of rgdal the required components are libgdal-dev & libproj-dev. To install this additional components one should get the ID of container and enter this container with bash (in this example container ID is bd6b621298a3):

docker ps
docker exec -it bd6b621298a3 bash

Inside the container execute:

apt-get update
apt-get install libgdal-dev
apt-get install libproj-dev
apt-get install tk tcl
apt-get install tk-dev tcl-dev
apt-get install tk8.5 tcl8.5
Then exit the container typing
exit

9) After successful installation of all necessary packages in RStudio web interface the configured container should be saved as a new image with tag my (or any other tag).

docker commit bd6b621298a3 rocker/rstudio:my
docker images

10) Run one or more independent instances of container from the image created in step 9, using different port for each instance. Don't forget to specify data sharing directory to be able to access data. For example, the following code is to run two RStudio containers connected to ports 8787 & 8788, and data directory in C:/Users/vshal/Documents.

docker run -v /c/Users/vshal/Documents:/data -d -p 8787:8787 rocker/rstudio:my
docker run -v /c/Users/vshal/Documents:/data -d -p 8788:8787 rocker/rstudio:my
docker ps

11) Now you can connect with both RStudio server containers in two separate browser tabs, by changing the port number in the URL and then run two analysis tasks simultaneously. As well you can use the usual Windows RStudio installation absolutely independently from this RStudio server instances.

Читать дальше......