[R] communicate from Rterm

Duncan Murdoch murdoch at stats.uwo.ca
Fri Jan 11 15:30:25 CET 2008


On 1/11/2008 9:18 AM, stephen bond wrote:
> Please, help with announcing an error from Rterm:
> 
> I am calling R from an Excel VBA and noticed that if there is an error 
> nothing conspicuous happens. I would like just a popup window when R 
> cannot finish cleanly. The "ret " value returned from Shell is useless 
> in determining what happened.

This seems to be a VBA problem, not an R problem.  Rterm returns a 0 
return value when it exits cleanly, and a non-zero value when there's an 
error.  It looks as though you're losing that by wrapping the Rterm call 
in a batch file.  Can't VBA make the call to Rterm directly?

Duncan Murdoch

> 
> Thank you all.
> 
> *****************************
> Public Sub Repo()
> ds = InputBox("Type in reporting date as YYYY-MM-DD", "reporting 
> date")
> 
> ''-----   weird way to pass the date argument as Windows won't
> ''-----   execute the command line directly, so I create a .bat
> 
> exestr = "Rterm --restore --save --args " & ds & " < m.in.R > out.txt"
> Set fs = CreateObject("Scripting.FileSystemObject")
> Set a = fs.CreateTextFile("rpcd.bat", True)
> a.writeline (exestr)
> a.Close
> 
> ret = Shell("rpcd.bat")
> MsgBox ("wait for about 5 seconds as the script runs asynchronously")
> 
> End Sub
> 
> **************m.in.R************
> ds=commandArgs(T)[1]
> 
> ans=f.repo(ds)
> 
> q("yes")
> 
> ______________________________________________
> 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.




More information about the R-help mailing list