Showing posts with label c#. Show all posts
Showing posts with label c#. Show all posts

Saturday, May 3, 2014

Run R code from C#.

We have tryied to use R.Net to run R code in our project last week. Single runs were successfull.

But then problems started.

1. Initialize only one instance per process.

Current version 1.5.5 in nuget http://www.nuget.org/packages/R.NET/ can be created only one time. Second call to Initialize just hangs.

2. Crashes on 4th- 5th try

Last available version 1.5.11 http://rdotnet.codeplex.com/ throws exceptions on 4th or 5 th run. And almost never returns error message.

Our solution:

Our solution based on this answer on stackoverflow http://stackoverflow.com/questions/5025340/call-r-programming-language-from-net

With monor change, we send R code from string and save it to temp file, since user run custom R code when needed.

  Here is gist of test:



 Result, run over R scipt over 2000 times and no error.

Hope, saved your time.