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.

Best,
Uwe Ligges

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to