Calling R function from C#

1.7k Views Asked by At

Is there any way to call R function by using R.NET from C#?

I'm using Visual Studio 2017 and installed the latest version of R.NET. I had tried to use the codesearch from Google which using REngine.SetDllDirectory but Visual Studio show out an error:

<'REngine' does not contain a definition for 'SetDllDirectory'>.

2

There are 2 best solutions below

0
On

Yes it is possible.

Some Gotchas that I found:

1) Be sure to modify your VS 2017 install to include the Data science and analytical applications. This will install the R server onto your machine.

2) Run in 64bit mode only.

3) Get the vanilla hello world sample going first.

0
On

Given there is a COM interface to R, you can use C#'s COM interop to control it.

See this article for more details: http://www.codeproject.com/KB/cs/RtoCSharp.aspx