Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to change the file path for an Rstudio project?

Tags:

git

r

rstudio

I'm using GIT and I note that if I just move the whole folder (or rename it) in windows, that it breaks all the paths. I then end up in an infinite loop of trying to quit Rstudio and Rstudio unable to find the file path to save (or not save).

Is there a way to move the location of the project folder while keeping it still intact?

Sorry, let me make this clearer.

  1. Start Rstudio and create a version-controlled project (I'm using GIT)
  2. Realize that you put the project in the wrong folder of your computer
  3. Move the project to the new folder by (a) moving the Rstudio and GIT files to another location using windows explorer. (breaking all the links) or (b) start a new project in the 'correct' location. (losing the versions of your edits).
like image 581
Tom Avatar asked Jun 26 '12 08:06

Tom


People also ask

How do I change the path of a file in RStudio?

A default working directory is a folder where RStudio goes, every time you open it. You can change the default working directory from RStudio menu under: Tools –> Global options –> click on “Browse” to select the default working directory you want.

How do I change the directory of a file in R?

R is always pointed at a directory on your computer. You can find out which directory by running the getwd (get working directory) function; this function has no arguments. To change your working directory, use setwd and specify the path to the desired folder. dir – Specify a working directory.

How do I change the source location in R?

Step 1) Click on the Session tab. Step 2) Click on Set Working Directory > To Source File Location. Afterwards, you working directory will be changed to the location of your source file.


2 Answers

With RStudio closed, I moved the project folder (using Windows Explorer) to a new location. My RStudio project opened fine from there. I made an edit and pushed it to Github.

If you use the here package on Cran you won't have to update any links.

like image 157
Eric Krantz Avatar answered Nov 07 '22 02:11

Eric Krantz


If you use GitHub Desktop, it will detect that the project has been moved and allow you to locate (set) it to a different folder.

like image 44
ksrm Avatar answered Nov 07 '22 02:11

ksrm