On Windows, how to avoid Documents in OneDrive becoming the user's package directory?

I am an infrequent Windows users, so I am not sure where this setting arises, but it seems that the default directory for R packages for a user (and the value of R_USER env variable) ends up being the Documents folder inside the OneDrive folder of the user. In the past, I seem to recall it being the local drive Documents folder, which seems much more sensible.
Why does R end up using this folder? Where is the setting that determines this? I presume it is Windows setting, as opposed to a R setting?
Basically I want to choose another folder such as the Documents folder on the local drive rather than the OneDrive Documents folder.
This page How to fix RStudio’s package installation on Windows 10 | by José Duarte, PhD | Medium gives one solution, but that involves hardcoding the folder path into a R system wide settings file that previously read environment variables. Presumably, the better solution is to change either the environment variable value itself, or change whatever sets the default value of the environment variable.

Does any Windows based R/RStudio user have any solutions to this problem?

Yes, you are right, the default R home directory (when not in a project) is set to your Windows user's HOME directory, which is set to OneDrive when you configure your account to sync your local files with OneDrive.

If you don't want to set a different path in a startup file for R, then you could disable OneDrive syncing for your Windows account.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.