Neil Osborne
2003-Jul-19 15:39 UTC
[R] Method 'EvaluateNoReturn' of object 'IStatConnector' failed
Hi All, I am using the R ActiveX component (v1.2). I have written a custom function in R which returns a dataframe. I want to be able to retrieve the contents of the returned dataframe in my application. Here is a snippet of the code (line that throws exception). X has been correctly declared and init'ed earlier on in the code. x.EvaluateNoReturn("results_frame <- MyFunction()") I was intending to then invoke the GetSymbol method to retrieve the contents of results_frame into a local variable. I notice that this still dosen't work if I try to use the Evaluate method to directly assign the returned dataframe to my local variable. My questions can thus be summarised as ff: 1). How do I call a custom function written in R, using the R ActiveX library. ? 2). How do I access a dataframe returned from a function call, using the R ActiveX library. ? 3). Can I / How do I pass arguments into a function (including datframes) using the R ActiveX library. ? Many Thanks PS: I am relatively new to R, and I suspect that my function is not loaded into R's memory space. When using R in the normal way (i.e. via GUI), I initially used the source() command to load the function script. However, I have saved it in the R workspace (default startup directory), and is thus loaded everytime R is started. I am assuming the using the R ActiveX library fires up R, which loads up the default workspace - but I may be doing something wrong. Any help will be greatly appreciated. Thanks _________________________________________________________________ Find a cheaper internet access deal - choose one to suit you.
Prof Brian Ripley
2003-Jul-19 17:01 UTC
[R] Method 'EvaluateNoReturn' of object 'IStatConnector' failed
On Sat, 19 Jul 2003, Neil Osborne wrote:> I am using the R ActiveX component (v1.2). I have written a custom function > in R which returns a dataframe. I want to be able to retrieve the contents > of the returned dataframe in my application. > > Here is a snippet of the code (line that throws exception). X has been > correctly declared and init'ed earlier on in the code. > > > x.EvaluateNoReturn("results_frame <- MyFunction()")That is not a valid R command: underline is not part of a syntactically valid name and has been made defunct (in the development version which will become 1.8.0). Depending on your version of R this will be an error or give a warning and mean results <- frame <- MyFunction()> I was intending to then invoke the GetSymbol method to retrieve the contents > of results_frame into a local variable.Won't work as there cannot be such a variable name (unquoted).> I notice that this still dosen't work if I try to use the Evaluate method to > directly assign the returned dataframe to my local variable. > > > My questions can thus be summarised as ff: > 1). How do I call a custom function written in R, using the R ActiveX > library. ? > 2). How do I access a dataframe returned from a function call, using the R > ActiveX library. ? > 3). Can I / How do I pass arguments into a function (including datframes) > using the R ActiveX library. ?In all cases, the same way you do at R's command line. So do check your scripts at the command line where you will get more informative error messages and recover options. [...] -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595