Someone out there has kindly adapted R to the Portable Apps framework!

This means we can use R and R-Studio anywhere we like without needing to install R and R-Studio locally, quite handy for work, University computers and VM’s. We can also keep all our libraries and packages in one location making them easier to manage when moving between workstations.

A few quick notes,

R’s filesystem scheme is Unix based so where windows would use “\” R and Unix/MacOS use “/”

Second I will be using “~” to indicate starting in our home drive or home directory. In most systems the “~” modifier will direct you to your actual “home” directory, usually a user folder.

1
Create a folder you would like to work on that can be shared, a cloud storage syncing system (dropbox or onedrive) or a USB stick work, for me, using dropbox, my directory is “~/Dropbox/R Portable”

2
We need R Portable (the language) which can be found at https://sourceforge.net/projects/rportable/files/R-Portable/3.5.3/
Download R-Portable 3.5.3 to your new directory “R Portable”
Install to your directory (windows might throw up an error)
After this you can remove the installer

3
We need the ZIP version of R-Studio, this is found on the usual R-Studio download page,
https://www.rstudio.com/products/rstudio/download/
But a bit further down the bottom, look for the Zip/Tarballs archive version
Extract this to your “~/R” Portable directory
You can now remove the zip

4(optional) Now might be a handy time to make it easier to access the R executable, make a new shortcut in your “~/”R Portable" directory, browse to this directory in your extracted R-Studio folder “~/R Portable/R-Studio Portable/bin/rstudio.exe

Double click your new shortcut and R-Studio will start!

5
The first time you start your new portable version R-Studio you will be asked to direct it to a current version of R. Browse to “~/R Portable/R-Portable/App/R-Portable” and click “select folder”.
Not the most intuitive naming but it’ll get you there. Then select the appropriate version, either 32-bit or 64-bit.

6
Now we want to keep what we do in one place, so we should set our work directory to be in our portable location. To do this we can use the “setwd” function, for example

setwd("G:/Dropbox/R Portable/Portable Work Directory")

First we must create the new working directory folder, in my case “Portable Work Directory” preferably in our R Portable directory. Once this is complete just use setwd with the full directory path.
Remember if you’re on windows to swap “\” with “/”

7
Our next challenge is libraries, keeping your libraries consistently with your newly portable R and R-Studio installations requires a little code.
We can temporarily change our library location within R-Studio using libPaths,

Create your directory in the ~Portable folder, I chose “Portable Libraries” then use libpaths to direct R Studio to our new directory

.libPaths("G:/Dropbox/R Portable/Portable Libraries")

This will add our new path to the library paths list in the default position. However, this will only work for a continuous session of R-Stuido, to make these changes permanent you can add the same code to your Rprofile file, located in
“~/R Portable/App/R Portable/library/base/R”
append the above code to this file and when R-Studio starts it will automatically be directed to your new R libraries folder.

And We are finished!

We now have a fully portable version of R, R-Studio, all your packages and libraries, and as long as you save them to your portable location Rproject files. If you can’t use a cloud service like dropbox simply copy your full directory to a USB drive and you can run it directly from the drive.

Good Luck!