[R] open/execute/call/run an external file

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Aug 22 07:11:57 CEST 2007


On Tue, 21 Aug 2007, STEPHEN M POWERS wrote:

> I'm trying to figure out how to trigger a process from within R. I have 
> an exectuable file that runs a Fortran model, but ideally, would like to 
> run it from R. Note that I'm not talking about importing the function at 
> all, passing variables, or anything complicated like that. I basically 
> just want a script that "double-clicks" on a particular file and 
> opens/runs it for me.
>
> The idea here is that the executable Fortran file, when double clicked, 
> simply draws all necessary inputs from text files within the same 
> directory and I have no need to change this. So I've used R to summarize 
> some raw data and format these required text input files in the way the 
> Fortran executable requires, and also have scripts to interpret the 
> Fortran text file outputs and summarize/plot them in R. The problem is I 
> must run the first part of the R script to send data from R to the 
> model, then double click the Fortran executable, then run the second 
> part of the R script to get the model outputs into R, in three separate 
> steps. Given that I may be doing this hundereds of times, I'd prefer to 
> do it all in one step.
>
> Any thoughts?---steve

It is described in the relevant manual: Writing R Extensions.
?system, and if this is Windows also ?shell and ?shell.exec.

> ______________________________________________
> R-help at stat.math.ethz.ch 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.

When you do, you will see that we asked for your OS which is relevant 
here.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list