[R] Help needed - Use of RSrvr in macro mode
Uwe Ligges
ligges at statistik.uni-dortmund.de
Thu May 26 16:45:20 CEST 2005
This is a VERY special question. Please redirect your question to the
appropriate mailing list. See
http://mailman.csd.univie.ac.at/mailman/listinfo/rcom-l
for more information.
Uwe Ligges
Constant Depièreux wrote:
> 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
>
>
>
> ------------------------------------------------------------------------
>
> smalltest=function(extvar)
> {
>
> itworks=paste('Ca marche',date())
>
> setwd("c:/windows/temp")
>
> write.table(itworks,file="resultat.csv", append=FALSE)
>
> }
>
>
> ------------------------------------------------------------------------
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
More information about the R-help
mailing list