Back to Homepage

Backup & Sync R Libraries

Feng Jiang
Last Updated: 2020-11-17

In the past, every time when I setup a new machine, I had to reinstall the R libraries. So, like many others, I exported the list of the R libraries I use from the old machine, and then install those libraries on the new machine.

What is more annoying is that because I use R on multiple machines, from time to time, I found that after installed and used a new package on machine A, code would be broken on machine B, and then I realized that I need to install the new package on machine B.

I recently found that these annoying processes can be easily solved with cloud service. 

R packages, by default, are saved in your "Documents" folder, under Documents\R\win-library\{R-version}. And some cloud drive apps like OneDrive, Dropbox, and many others, can synchronize your "Documents" folder to the cloud, and sync between multiple machines. 

So, all you need to do, is simply letting your cloud drive synchronize your "Documents" folder. Take OneDrive as the example, go to settings, click "Backup", and then click "Manage backup", and then chose the "Documents" folder.

Unless you changed the default R library folder, your R libraries should be backed up to the cloud and synchronizing among your computers now. 

If your different machines have different R versions installed, this shouldn't be a problem, because R library folder is organized by different R versions.

© 2020