Where the information of working directory is stored


#1

I created a R project a couple of days ago, however, every time when I access it I just click the R script file instead of the R project file, but it seems that RStudio still sets my folder of R script as working directory, which is quite desirable. I thought the R project file is to make sure the current folder is set as working directory. My question is how RStudio decides which folder to set as working directory if my R script is updated while R project is not.


#2

If you open a project, then the location of the .Rproj file will be the working directory. To use a project properly/cleanly you should store .R scripts in a folder under the working directory, so there will be a relative path to them.

That said, if you open scripts from other locations from within a project then the working directory should not change. Without knowing what you have done in detail it's difficult to understand your issue.