RStudio: Open Source File in New Window Using rstudioapi / navigateToFile

I have a set of helper functions that open groups of related source files. This works great, except for one issue: I would like to open the files in a new window.

Here's basic code: <- function(Group = "OUT_CONFIG"){
        if(Group == "OUT_CONFIG" | Group == "YAML")
        if(Group == "OUT_CONFIG" | Group == "LATEX")

How can I get these files to open to a new window, instead of just having them all open in the main window.

Rstudio allows for a "new window" using the GUI in the taskbar by clicking on the taskbar button to launch new window:

I would like to be able to do the same using code.

Would love to know if anyone has an tips.

Thank you!

I couldn't help but notice that you recently posted a very similar question on and on a different website.

The current way you've done this is generally considered not-OK

From: FAQ: Is it OK if I cross-post?

I apologize. After my original post on Stackoverflow, I was advised on StackOverflow to post here - suggesting that this was the appropriate venue. I can place a link from Stackoverflow to the solution here or do whatever else you think is appropriate.

I suspect you're not going to be able to do it without hacking around a bit LOT. After digging around a bit more I think you'd need to run your own forked R Studio and add an API function which can move source tabs between editors. It could be done, but unless it's absolutely critical to be able to do, your energies are probably better spent elsewhere.

This is the XML list of commands which contains the commandIDs you can invoke using executeCommand(). A particular one of interest is on line 1192, popoutDoc. Running the command,


Will pop out whatever the active tab is in the editor window, so, you could first navigating to a file then pop it out.

This, unfortunately, will pop out each file into its own source editor window and I don't see a way to programatically move tabs between editor windows.

By playing around with it you might see or find somethign I did not, but this is one place you might start your attack.

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.