On 03/08/2007 7:16 PM, Christopher Green wrote:
> Is there an easy way to open an R script file in the R Editor found in
> more recent versions of R on Windows via a file association? I am looking
> for functionality akin to how the ".ssc" file extension works for S-Plus:
> upon double-clicking on a ".R" file, Rgui.exe starts up and loads the script 
> file in the R Editor.
> 
> As far as I can tell, Rgui.exe does not have a command line option to load
> a file (so associating ".R" with "Rgui.exe %1" won't work). I can get Windows
> to start Rgui.exe when I double-click on a script file, but that's about it.
> I also don't see any way to have Rgui.exe evaluate an expression provided on
> the command line (which would allow "file.edit(%1)"). I also thought about
> creating a custom .First calling 'file.edit' in a batch file, but then I'd 
> have
> to start R, load the .First file, then quit and restart R, so that's out.
> 
> Is there an easy way to do this without resorting to some other R GUI?

Easy?  Not sure.  But the following works:

Set up the association as

"F:\R\R-2.5.1\bin\Rgui.exe" --args "%1"

(with obvious modifications to the path) and put this line in your 
RHOME/etc/Rprofile.site file:

utils::file.edit(commandArgs(TRUE))

You could make things more sophisticated if you don't want a blank edit 
window to open in case you're not using this shortcut.

Duncan Murdoch

______________________________________________
[email protected] mailing list
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