[R] Help needed - Use of RSrvr in macro mode

Constant Depièreux constant.depiereux at aqte.be
Thu May 26 11:12:02 CEST 2005

Dear All,

I am experiencing a problem for which I need some help.

I have created a small file containing a simple function

File name = smalltest.r

Content :


itworks=paste('Ca marche',date())


write.table(itworks,file="resultat.csv", append=FALSE)


This function works when operated from R environment

To get it performed from Excel, I have write a small function as follows :

Excel file : see attachment (one sheet named 'test', one cell A1 
containing : smalltest(NA))

Macro :

Sub smalltest()

    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select
    Call RInterface.StartRServer
    Call RInterface.RunRFile("h:\R-Sources\smalltest.r")
    CommandString = Range("test!a1")
    MsgBox (CommandString)
    Call RInterface.RRun("CommandString")
    Workbooks.Open Filename:="c:\windows\temp\resultat.csv"
    Range(Selection, Selection.End(xlToRight)).Select
    Range(Selection, Selection.End(xlDown)).Select

End Sub

Function works (i.e. does complete without error message) when 
c:\windows\temp\resultat.csv exists (created using above smalltest 
function in R environment) but hangs when operated from excel (file not 

My machine is a 4 Gb Memory - PIV 3.2Ghz  with disk mirroring running 
latest update of XP Pro SP2.

Both R and RServer are latest editions available.

Does anybody have an idea of what the problem might be?

Many thanks for your advices.

Best regards.

Constant Depièreux

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: smalltest.r
Url: https://stat.ethz.ch/pipermail/r-help/attachments/20050526/f7f4e89c/smalltest.pl

More information about the R-help mailing list