Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# - R interface

Tags:

I need to interface R to some C# application. I installed rscproxy_1.3 and R_Scilab_DCOM3.0-1B5 added COM references to the STATCONNECTORCLNTLib, StatConnectorCommonLib and STATCONNECTORSRVLib but I still cannot get it working.

When I run following test program:

using System; using System.Collections.Generic; using System.Linq; using System.Text;  //COM references using STATCONNECTORCLNTLib; using StatConnectorCommonLib; using STATCONNECTORSRVLib;  namespace R_TESTING {     class Program     {         static void Main(string[] args)         {             StatConnector sc1 = new STATCONNECTORSRVLib.StatConnectorClass();                      sc1.Init("R");         }     } } 

I get this exception:

Unhandled Exception: System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x80040013    at STATCONNECTORSRVLib.StatConnectorClass.Init(String bstrConnectorName) 

Thanks in advance.

UPDATE: Ok, still no luck. I will try to explain what I did so far.

Installed R-2.12.2-win.exe from rproject to the C:\Program Files\R\R-2.12.2

Downloaded rscproxy_1.3-1.zip and copy/pasted it to the C:\Program Files\R\R-2.12.2\library

Installed R_Scilab_DCOM3.0-1B5.exe to the C:\Program Files (x86)\R\(D)COM Server

With Scilab comes a basic test. I tried to run it but I got following error:

Loading StatConnector Server... Done Initializing R...Function call failed Code: -2147221485 Text: installation problem: unable to load connector Releasing StatConnector Server...Done

Than I looked in the PATH/System Variables and found no path/R_HOME/R_USER info. Also, I couldn't find anything R related in the registry.

I guess I am doing something terribly wrong, so I desperately need help from you guys.

like image 361
Klark Avatar asked Mar 21 '11 11:03

Klark


People also ask

What C is used for?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

What is the full name of C?

In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.

What is C in C language?

What is C? C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.

Is C language easy?

C is a general-purpose language that most programmers learn before moving on to more complex languages. From Unix and Windows to Tic Tac Toe and Photoshop, several of the most commonly used applications today have been built on C. It is easy to learn because: A simple syntax with only 32 keywords.


2 Answers

You can have a look at R.NET, for another approach...

like image 133
teucer Avatar answered Oct 20 '22 00:10

teucer


Ok, I solved it finally. The problem is that R (D)Com doesn't work with current version of R. I installed 2.11.1 and it worked out of box.

Thanks a lot.

like image 25
Klark Avatar answered Oct 19 '22 23:10

Klark