[R] Associate a .R file with the RGui
Amarjit Chandhial
@@ch@ndh|@| @end|ng |rom bt|nternet@com
Mon Nov 7 15:26:02 CET 2022
Hi Uwe,
Many Thanks.
Amarjiit
> On 7 Nov 2022, at 14:00, Uwe Ligges <ligges using statistik.tu-dortmund.de> wrote:
>
>
>
>> On 06.11.2022 19:43, Amarjit Chandhial wrote:
>> Hi Uwe,
>> I can do 1.
>> 1. Add the line
>> if ( length(z <- commandArgs(TRUE)) ) utils::file.edit(z[1])
>> to the Rprofile.site file; and
>> My Rprofile.site file is: "C:/PROGRA~1/R/R-42~1.2/etc/Rprofile.site"
>> How do I do 2, step-by-step?
>> 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"
>
> If you have not .R file association yet, you can add the line above when being asked.
> If you have one, simply change the registry key
>
> Computer\HKEY_CLASSES_ROOT\R_auto_file\shell\open\command
>
> There is a standard value as extendable string (REG_EXPAND_SZ) and you simply replace its content by
>
> "C:\Program Files\R\R-4.2.2\bin\x64\Rgui.exe" --args "%1"
>
>
> and in
>
> Computer\HKEY_CLASSES_ROOT\.R
>
> there shoudl be a standard string (REG_SZ)
> R_auto_file
>
> Best,
> Uwe Ligges
>
>
>
>
>
>> Amarjit
>> ------ Original Message ------
>> From: "Uwe Ligges" <ligges using statistik.tu-dortmund.de>
>> To: "Amarjit Chandhial" <a.chandhial using btinternet.com>; "David
>> Winsemius" <dwinsemius using comcast.net>; "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 17:19
>> Subject: Re: [R] Associate a .R file with the RGui
>> On 06.11.2022 17:21, Amarjit Chandhial via R-help wrote:
>>
>> 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
>> script.
>> 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
>> script.
>> From the adaptation, if I choose R for Windows GUI Front-end, will the
>> .R file open in RGui (64-bit) within the editor?
>> Yes.
>>
>> 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.
>> I meant to implement that one can choose the internal editor to open
>> .R files. File associations can be set by RStudio, too, but that is
>> not an R(-core) matter.
>> Best,
>> Uwe Ligges
>>
>> thanks,
>> Amarjit
>> ------ 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
>> <https://stat.ethz.ch/pipermail/r-help/2007-August/138064.html>
>> <https://stat.ethz.ch/pipermail/r-help/2007-August/138064.html
>> <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
>> [[alternative HTML version deleted]]
>> ______________________________________________
>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> <https://stat.ethz.ch/mailman/listinfo/r-help>
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> <http://www.R-project.org/posting-guide.html>
>> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list