I’m trying to write an R-Excel vba addin and am having trouble using GetArrayToVBA.
Example:
RInterface.StartRServer
RInterface.RRun "mytst<-4"
Dim tstVar As Variant, tst As Double
tstVar = RInterface.GetArrayToVBA("mytst")
tst = CDbl(testVar)
MsgBox "count = " & CStr(tst)
RInterface.StopRServer
Results in messagebox showing count = 0. I was expecting count = 4.
This is a VBA issue. You can’t typecast a 1×1 array into a double with CDbl() to get the value that’s in that array. You have to give it the index (0,0) that you want from the array. The following works: