melbez
melbez

Reputation: 1000

Create new project in new session in R

Is there a way to create a new project in a new session?

When I press "New Project" with a project already open, R asks me if I would like to save the workspace image of the current project. It then closes the current project. There is an option for "Open Project in New Session" for pre-existing projects, but I don't see a way of creating a new project.

Upvotes: 3

Views: 1780

Answers (2)

Dominic van Essen
Dominic van Essen

Reputation: 872

I've just read the accepted answer (@Len Greski) to this, which shows a feature that I was never aware of despite using RStudio for quite a long time!

If you are using Mac OS, though, I can also propose an alternative, 'one-click' approach, which is what I use and which works very well. There may be similar variants of this that may work on other operating systems (and if so, please feel free to edit them into this reply, or in the comments).

You can open a 'new' instance of 'RStudio' from a shell command-line using:

open -n /path/RStudio
# replace /path/RStudio with the path to your RStudio installation

You can use this to open as many simultaneous RStudio instances as you like, which each run their own R sessions independently.

To make this into a 'one-click' approach, you can 'wrap' the command-line call into an application (which I keep in the Mac OS 'dock'). I used the 'appify' script by Thomas Aylott / Matthias Bynens: see https://gist.github.com/mathiasbynens/674099.

This now sits in my 'dock', and clicking on it will open a new RStudio instance:

enter image description here

Upvotes: 0

Len Greski
Len Greski

Reputation: 10855

In RStudio, after selecting New Project from the project pulldown in the upper right corner of the screen, RStudio asks whether to save the current workspace and brings up a New Project dialog box.

enter image description here

After selecting Existing Directory, the next window includes a checkbox to create the project and open it in a new session. If one checks the checkbox, RStudio keeps the previous project open and creates the new project in a second RStudio session.

enter image description here

Upvotes: 4

Related Questions