Using R (D) COM to integrate R with C #

I am trying to use the R (D) Com interface. I have R 2.12.1 installed on the machine. To use this interface in C #, I downloaded the rscproxy_1.3-1 package and then installed R_Scilab_DCOM3.0-1B5 on my machine. In addition, I copied sciproxy.dll from Program Files \ R (D) COM Server \ Scilab to Program Files \ R (D) COM Server \ bin, as reported during the installation of the interface.

My problem:

As part of the testing, I tried the code from the blog post http://vvella.blogspot.com/2010/08/integrate-c-net-and-r-taking-best-of.html . But my form application failed due to an exception thrown by the rconn.Init ("R") statement. The exception was the text Exception from HRESULT: 0x80040013 I tried to run samples from programs-> R-> R (D) COM Server-> Server 01 Basic Test. In the launched form, I clicked the "Run R" button, but with the error printed in the text box, "R initialization error ... Function error" Code: -2147221485 Text: Installation problem: Connector cannot be loaded "

I tried this:

I tried to fix it using the html index page, and there, in the installation section, I found that rproxy.dll should be in the installed R / Bin folder. In addition, HKEY_LOCAL_MACHINE \ Software \ R-core \ R \ InstallPath must point to the installation folder.

Things missing on my car

  • Installed R / bin folder Do not enter rproxy.dll. Where can i get this dll? Or is it sciproxy.dll instead?
  • HKEY_LOCAL_MACHINE \ Software \ R-kernel \ R \ InstallPath points to the installation folder, but in HKEY_CURRENT_USER \ Software.

I can guess that there is something suspicious about installing or registering a COM server. But I can’t figure it out.

Could you tell me where I am wrong?

thanks,

Capil

+7
source share
2 answers

Oh god, I remember that it was a huge pain in the ass. Let's see if I remember ... And before I start, I warn you that I just “got this job” and never cared about it if I could remove parts from the process.

Downloading is done from http://rcom.univie.ac.at/download.html . If I remember correctly, the RandFriends package is all you need, it installs crapload (just install it all), but is simple. Alternatively, I think that if you install the “rscproxy” package in R, you can simply download “statconnDCOM” and install it. The memory is foggy, but I know that one of these methods leads to an annoying splash screen every time you run your C # executable, and the other does not. Although, perhaps this was some setting with which I played.

Now I can’t remember how you verify that the material has been successfully installed. Although, of course, these are examples. Once this starts, open your C # project. Indicate the following projects,

StatConnectorCommonLib STATCONNECTORSRVLib 

In your code, you probably want to implement IStatConnectorCharacterDevice in order to get the R output returning to C #. Your initialization code will look something like this:

 private StatConnector _StatConn; private IStatConnectorCharacterDevice _CharDevice; private Whatever() { // declare _StatConn = new StatConnectorClass(); _CharDevice = new MyCharDevice(); // init R, wire up char device _StatConn.Init("R"); _StatConn.SetCharacterOutputDevice(_CharDevice); } 

Then you should just use functions as needed

 _StatConn.EvaluateNoReturn("x <- 3"); var returnObj = _StatConn.Evalute("1 + 1"); 

Hope this helps.

tl; dr download RAndFriends, do a new installation using

+4
source

I had a similar problem with calling R.Init (), I found R.GetErrorText () returns the actual error message

0
source

All Articles