[R] Associate a .R file with the RGui

Amarjit Chandhial @@ch@ndh|@| @end|ng |rom bt|nternet@com
Sun Nov 6 17:21:23 CET 2022

Hi Uwe,

RGui does have advantages vs. RStudio, and vice-versa.

RStudio is much faster than it used to be.

I currently have .R files associated with RStudio, i.e. in File Explorer 
if I double-click on a .R file it opens in the editor in RStudio as an R 

In File Explorer if I right-click on a .R file, Open with, I get the 
options: R for Windows GUI Front-end or RStudio or Search the Microsoft 
Store or choose another app.
If I choose R for Windows GUI Front-end, RGui (64-bit) opens, but no .R 
file, in the editor.
If I choose RStudio the .R file opens in the editor in RStudio as an R 

 From the adaptation, if I choose R for Windows GUI Front-end, will the 
.R file open in RGui (64-bit) within the editor?

I have a new Windows PC and maybe, at least for the time being, it's 
best for me to have them associated with RStudio.

Although, yes, I agree, it should be naturally implemented in R, having 
installed RStudio.


------ Original Message ------
From: "Uwe Ligges" <ligges using statistik.tu-dortmund.de>
To: "David Winsemius" <dwinsemius using comcast.net>; "Amarjit Chandhial" 
<a.chandhial using btinternet.com>; "Jeff Newmiller" 
<jdnewmil using dcn.davis.ca.us>
Cc: "Amarjit Chandhial via R-help" <r-help using r-project.org>
Sent: Sunday, 6 Nov, 2022 At 15:15
Subject: Re: [R] Associate a .R file with the RGui

  On 06.11.2022 01:40, David Winsemius wrote:

  On 11/5/22 09:58, Amarjit Chandhial via R-help wrote:
  Hi Jeff,

  Please see my original question.

  You were told that RGui is not an editor.

  Are you implying that your initial message contained an implicit 
request for instructions on how to get R code in an .R file to be opened 
automagically when double-clicked or to have "open in <some editor>" 
appear when right-clicked? (I didn't see that clearly expressed.)

  If you want something else to happen with a file that has a .R 
extension when double-clicked or right-clicked in a GUI file manager, 
then you need to configure your OS to do whatever else it is that you 
expect. This is not really an R question. It's an OS question. There are 
many editors that can also bring up R consoles when the right  key combo 
is pressed. They do require some study for their specific actions, but 
this is not really the place to get guidance on the fine details.

  Friends, RGui contains an editor. It allows to send lines / code 
blocks to the R concole. We know users who need braille displays use the 
RGui internal editor as that apparently cooperates better with braille 
displays + R as many other editors.
  And as it does not hide half of R by its own functions, I'd pefer that 
over some very popular other editors if I had no other choice.

  To answer the OP's question, R does not have a built in way to get 
this task directly done, but searching the web suggests a rather simple 
way (well,m a hack as starting R with other command args may fail now, 
but you can extend this and look for a specific naming scheme):

<https://stat.ethz.ch/pipermail/r-help/2007-August/138064.html> >

  let is adapt this for the recent version of R:

  1. Add the line

  if ( length(z <- commandArgs(TRUE)) ) utils::file.edit(z[1])

  to the Rprofile.site file; and

  2. Edit the registry to associate the .R extension with the command

  C:\Program Files\R\R-4.2.2\bin\x64\Rgui.exe --args "%1"

  I think we should implement this in R anyway.

  Uwe Ligges

	[[alternative HTML version deleted]]

More information about the R-help mailing list