0

Having progressed my initial test of getting c#, R to work in our MVC web environment. I was trying to get the following code to work (taken from -> http://rdotnet.codeplex.com/)

To investigate this so far I have launched R from a cmd prompt and proven that I can enter these statements in R and get results, so I know that R is working. I have also run a very simple "Hello World" example proving that I can launch the R engine and get results back.

Then I wanted to go to a more complex question and I thought of Doing the Code from the codeplex.com page. To do something a bit more worthwhile than saying hello...

This is the snippet below. The Engine has already been created and I know is functioning from a previous test.

NumericVector group1 = Engine.Evaluate("group1 <- c( 30.02, 29.99, 30.11, 29.97, 30.01, 29.99)").AsNumeric();
NumericVector group2 = Engine.Evaluate("group2 <- c( 29.89, 29.93, 29.72, 29.98, 30.02, 29.98)").AsNumeric();

// Test difference of mean and get the P-value.
// what is in testResult
var testResult = Engine.Evaluate("t.test(group1, group2)").ToList();

at this point it errors and I get the message "Error in the application" and the following stack trace...

at RDotNet.REngine.Parse(String statement, StringBuilder incompleteStatement)
at RDotNet.REngine.<Defer>c__Iterator4.MoveNext()
at System.Linq.Enumerable.LastOrDefault[TSource](IEnumerable`1 source)
at RDotNet.REngine.Evaluate(String statement)

So my multiple questions on this are: -

is the example in the codeplex page Wrong? have I not done something? What does it mean? I feel that "error in the application" is not helping me find what I should do... Should I try some other examples or is the opinion of Dieter Menne in this stack overflow question the prevalent stance "unable to connect to R from c#" and I should move to the COM approach found here http://www.codeproject.com/Articles/25819/The-R-Statistical-Language-and-C-NET-Foundations

Although I am more interested in the mathematic and statistical rather than graphing.... I do want to make RDotNet work.... in c#

1 Answer 1

1

To answer your several questions:

  • R.NET is a work in progress, a lot has happened in the past 3-4 months and is currently happening, so I would not base my judgment solely on stances in previous stackoverflow posts that are many months old, when the work had been less active for quite some time prior to that.
  • Technically, and more to the point of your question: usually the ParseError with 1.5.5 occurs when forgetting to call engine.Initialize(). I agree the lack of message is irritating; this is being worked on for the next release.
  • There may be inherent issues with calling R.NET from a 'Web' environment. Very unfamiliar with is, but there are several reports: most recently https://rdotnet.codeplex.com/discussions/463226, and in particular https://rdotnet.codeplex.com/discussions/462947 sounds a lot like yours. I have successfully used R.NET as a back-end in R to Shiny, but cannot comment on ASP.NET.

Documentation and latest developments:

  • To get started, there are several sample projects on a git repo as I started an Onboarding guide. It is linked from the R.NET codeplex site. If this is where you got it and nevertheless have this ParseException issue, then let me know.
  • I've focussed my recent R.NET recent contributions around usability and robustness. I can propose, if your issue still persists, that you try to get the latest branch named 'jperraud' to compile R.NET. Happy to get feeback. The 'Onboarding guide has a branch https://github.com/jmp75/rdotnet-onboarding/tree/rdotnet-dev

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.