[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 :
smalltest=function(extvar)
{
itworks=paste('Ca marche',date())
setwd("c:/windows/temp")
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("A3").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.ClearContents
Call RInterface.StartRServer
Call RInterface.RunRFile("h:\R-Sources\smalltest.r")
Windows("smalltest.xls").Activate
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
Selection.Copy
Windows("smalltest.xls").Activate
Range("A3").Select
ActiveSheet.Paste
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
found).
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