Create new project in new session in R - 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.

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.
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.

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:

Related

R fails to attach to the terminal in certain workspaces in Visual Studio Code

I have been using RStudio for a while and recently switched to Visual Studio Code. Until recently, I had no issues opening any files or workspaces, but now when I open some workspaces it seems that R fails to attach to the terminal. I get no errors when I click "R: (not attached)" and ".vsc.attach()" shows up in the terminal like normal but nothing changes. Screenshot of terminal after attempting to attach R to terminal. If I open a new Visual Studio Code window and open a single file, not in a saved workspace, it opens normally and R attaches without any input from me. Screenshot of terminal after opening a new window and file not in a workspace. If I open the same file, not in a saved workspace, and then save the workspace, R is no longer attached and will no longer attach to the terminal. I tried using the fix from this post and added the code from the answer but nothing changed once again.
I started with a fresh install of Visual Studio Code from the website, not the Microsoft store, and did not sign in or sync my settings. I went through the process of setting up R again and used "C:\Program Files\R\R-4.2.1\bin\x64\R.exe" as Rpath and Rterm, which seems to be working so far. I will update my answer if the issue comes back or if I find another solution.

Atom randomly open files in new window (in stead of in new tab)

The issue is that when i allready have a project opened in Atom and i try to open another project (weather i use atom . from the command line or file > Open from the Atom menu) Atom seemingly random opens the project in a new window instead of in a new tab of the current instance.
I'm really getting fed-up with this because i don't want to navigate between three Atom instances to switch between projects. I just want all my projects in one Atom instance and switch between tabs.
Sometimes however Atom opens a new project in a new tab of the current instance, but unfortunatly that is the minority.
Does anybody else have this issue or know how i can force Atom to always open a new project in a new tab?
I'm on MacOS 10.13.6 and Atom 1.29.0
Below a screencast of the issue:
Since it's pretty hard to see, i justt do atom . from two directories
As mentioned in the Atom help output, there's a logic to it.
Usage:
atom [options] [path ...]
atom file[:line[:column]]
One or more paths to files or folders may be specified. If there is an
existing Atom window that contains all of the given folders, the paths
will be opened in that window. Otherwise, they will be opened in a new
window.
However, you can use the --add flag to add files or folders to the last used window of Atom.

Simultaneous sessions of Rstudio

Is it possible to somehow open several RStudios at the same time? I have Rstudio open, and when I try to open another one, nothing happens. What is the proper way to work on several projects simultaneously in RStudio?
If your work is contained in a separate RStudio project file, it should be as simple as selecting "Open Project in New Session", either from the File menu or from the project selector in the upper-right (at least on a Mac).
On a Windows machine you can "scroll click" on the icon and it will open a new session. You could probably also right click and choose something, not on a PC right now so cant tell for sure.

Freopen() not working in SDL

I tried using freopen() to redirect the "cout" function to the console, but it doesn't produce the desired effect. Instead of just double clicking on the executable and having the console show it's message, I need to use a command prompt or a batch file, and that's a problem, because I want the user to be able to close the console after the message has been displayed without closing the SDL window. This is supposed to be a console application. I apologize if I am not clear enough.
If using freopen() doesn't work the SDL Console FAQ gives a tutorial on recompiling the SDLmain library that is relatively easy to understand, especially if you already have MSYS and MinGW installed. You can use the resulting SDLmain library instead of your current one and it should work (It did for my project).

Consoles and Tabs

When I start the tomcat server from console using the startup.bat script, a new command window opens which is filled with java logging statements.
I use Console2 which leverages tabs for each open console window. Is it possible to let the java system create a new tab within console2 instead of just opening a new command window?
This has nothing to do with java, its merely down to the way the catalina.bat is called from startup.bat
catalina.bat can be called with either a "start" argument or a "run" argument.
run Start Catalina in the current window
start Start Catalina in a separate window
So open startup.bat, scroll to the bottom you should see
"%EXECUTABLE%" start %CMD_LINE_ARGS%
change that to
"%EXECUTABLE%" run %CMD_LINE_ARGS%
exit
I add an exit after to close the calling window.
Unless Console2 hooks any APIs that create console windows – no. And that's also highly unlikely that they do or even can. Console2 does nothing more than hook up input and output of console windows. What the programs in those do is beyond what it's interested in.

Resources