
Hi everyone,
I have the following problem:
I'm starting an Rfunction via VBA from Excel using the following code:
...
RInterface.StartRServer
RInterface.RRun "source(" & r_source & ")"
RInterface.GetArray "function1(" & x1 & "," & x2 & "," x3 & "," x4 & ")", Range(myRange)
RInterface.StopRServer
...
where "r_source" contains the path to the Rscript where "function1" is defined and the values for "x1", "x2", etc. are defined earlier in the VBA code. "function1" prints a matrix which is then writen into a sheet in my Excel file (in myRange).
When I define "x1", "x2", etc. directely in R and then evaluate "function1(x1, x2, x3, x4)" in R, the results are (as wished) only calculated once. But if I start it from Excel using the VBA code above, the results are calculated 4times before the matrix is written into Excel. Which of course is not very time efficient...
Does anyone have an idea how to solve this problem? That would be great!
Thanks a lot in advance! Greets,
Corinne
