Poojan (Wagh) Blog

Requests for comment

Archive for the ‘Data Science’ Category

Fixing OneDrive annoyance with Rstudio on Windows

without comments

By default, Rstudio on Windows with OneDrive installed stores packages in the OneDrive documents folder. This package location causes a lot of issues:

  1. It causes a lot of upload to OneDrive
  2. It can cause conflicts between machines (since they will be storing to the same OneDrive folder)
  3. It can cause unnecessary delays in having to download files from OneDrive (if they are not locally cached)

All in all, this location seems to be a poor side-effect of making OneDrive the default storage location on Windows. It can be easily rectified. Simply create a file called .Renvironment in “C:\Users\<username>\OneDrive\Documents” (AKA your OneDrive documents folder) with the following line:

R_USER="C:/User/<username>"

This one line redefines the user-specific directory to be on the local disk, in C:\Users\<username>. This is the exact same place as the %USERPROFILE% environment variable on Windows. The site-wide .Rprofile will make use of this variable and create an package path using it as a base.

These mechanisms are explained here, and it is simpler than editing the site-wide .Rprofile as described here (and many other places), which would require you to repeat the procedure on new installations (and also requires modifying files in the base installation path).

Written by Poojan Wagh

April 4th, 2022 at 8:37 pm

Posted in Data Science,MBA