Saving RStudio Projects to My Documents
Symptoms
Due to several static environmental variables in RStudio, the default install will not allow files to be saved to My Documents (the default home location). This can be seen by using the "setwd()" command to set it as the working directory and attempting to save the file. To resolve this, we must create a windows environmental variable named R_USER. The current environmental variable values can be seen in RStudio with the command "sys.getenv()".
Steps
After running the steps below, you should be able save to any location in RStudio on a faculty or staff laptop. Note that this change will also fix any issues with user libraries as R_LIBS_USER draws from R_USER.
Steps | Relevant Data and Screenshots |
---|---|
Create a new folder anywhere on your computer (your C:\ drive) except for your documents, desktop, pictures, or videos folders | |
In Search, search for and then select: Control Panel | |
Search for the Advanced system settings | |
Select Environment Variables | |
Under the User variables box, select New | |
Create a variable named R_USER and set the variable value to be the folder location you created in step one |
Related articles