Re: [R] communicate from Rterm

From: stephen bond <>
Date: Fri, 11 Jan 2008 15:14:38 +0000 (UTC)

I try with:

ret = Shell(exestr)

and it starts R, but the source file is not executed

inside R

> a=commandArgs()
> a

[1] "Rterm" "--restore" "--save" "--args" "2005-02-03" #correct date passed
[6] "<" "" ">" "out.txt"

it restores the correct workspace, but then it fails to source the script, which is located in the same dir as the workspace.

inside R

> source("") # does the job, so it is not a finding problem

BTW is it possible to get the error message from R somehow???

----Original Message----
Date: 01/11/2008 6:30
To: "stephen bond"<>
Cc: <>
Subj: Re: [R] communicate from Rterm

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
> nothing conspicuous happens. I would like just a popup window when
> cannot finish cleanly. The "ret " value returned from Shell is
> 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 & " < > out.
> 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
> End Sub
> **************************
> ds=commandArgs(T)[1]
> ans=f.repo(ds)
> q("yes")
> ______________________________________________
> mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code. mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Fri 11 Jan 2008 - 15:18:43 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 11 Jan 2008 - 17:30:06 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive