Change default location for open project

I think this is a basic question but i can't seem to find an answer.

When i open a project in Rstudio the default location is c:~

In my global options i have a different path set :(C:/Users/myName/Documents/MyWork ), however this is NEVER opened.

What am i missing? and how can i change the default location
thanks

You can change working directory at any time with setwd('your/path/here'), but it's best to work in a project. RStudio makes it pretty easy. When you start a new project, you can put it anywhere you like. Then when you open saved project (with "Open project" or by double-clicking associated .Rproj file), it'll open this project and working directory will be set automatically.

1 Like

@mishabalyasin Thanks. However I am not interested in changing directory. I am interested in changing the default location for when i select File->open project. Now of course there is a list of "recently opened" projects for me to select from but often i need to open another project not on the list. So when i click File -> new project i want the location to be where i keep all of my projects and not the folder c:~ which is currently the default.

RStudio normally tries to use your home directory as the 'root' when opening a new project. What is the output of:

Sys.getenv("HOME")
path.expand("~/")

in an R session on your machine?

@kevinushey right! So how to i change that? permanently, not just for the session. Is that in the global environment settings (windows 10). And was this path set (by the user) as HOME at time of installation?

Sys.getenv("HOME")
[1] "c:/~"

path.expand("~/")
[1] "C:/~/"

R reads your environment variables when determining the home directory, so you will have to edit those manually. See e.g. https://superuser.com/questions/949560/how-do-i-set-system-environment-variables-in-windows-10 for documentation on how these environment variables can be changed.

Note that you can also set the R_USER environment variable on Windows if you'd like to force R (and only R) to use a particular directory as home.

1 Like

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