[R] Invoking R from application

HBaize HBaize at buttecounty.net
Fri Aug 8 18:33:13 CEST 2008



I ran into the same problem when trying to launch R from MS-Access. 
The solution was to create a DOS batch file and execute it through 
VBA with the shell command. The batch file contains just one line:

C:\pathname\r\bin\rterm.exe --no-save < C:\pathname\rcode.r 

HTH


Duncan Murdoch-2 wrote:
> 
> On 08/08/2008 7:00 AM, Dobedani wrote:
>> Dear all,
>> 
>> I'm trying to invoke R from an application which I'm developing. I
>> have indications that the problem is specific to R. I'm able to e.g.
>> invoke a Python script in the same way with success, but R is giving
>> me problems. Last year a guy with nickname vital101 posted a message
>> on the Java forums website about invoking R from Java. The link to
>> that thread is:
>> http://www.java-forums.org/advanced-java/3433-external-program-execution-problems.html#post6970
>> 
>> Unfortunately, he did not report back whether he found a solution at
>> the time. As I said, I believe the problems he encountered were
>> specific to R. What he was doing from Java, I'm now trying to do from
>> C#. And I'm getting exactly the same warnings / errors back from R as
>> he was getting:
>> ARGUMENT '<' __ignored__
>> ARGUMENT 'test.r' __ignored__
>> 
>> FYI: I'm using Windows XP. If I enter the following behind the command
>> prompt:
>> C:\Progra~1\R\R-2.7.1\bin\Rterm.exe --slave < test.r
>> then my script test.r is dealt with correctly, but if I use DotNet
>> classes Process and StartInfo from the System.Diagnostics namespace,
>> things go wrong :-(
>> 
>> Does anyone understand what is going wrong here? Pls let me know
>> something. TIA
> 
> This is not a problem with R.  When you enter a command at the command 
> line, it is the shell (typically CMD.EXE in Windows) that handles the 
> input redirection "<".  R never sees that, and so R has no code to 
> handle it.
> 
> When you are invoking R directly, it's up to you to handle the input 
> redirection, since you're not using the shell.  I've got no idea how to 
> do that in C#.
> 
> However, R does allow you to use the -f (or --file=) command line option 
> to take input from a file, and that's likely to do what you want.
> 
> Duncan Murdoch
> 
> ______________________________________________
> R-help at r-project.org 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.
> 
> 

-- 
View this message in context: http://www.nabble.com/Invoking-R-from-application-tp18890219p18895118.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list