I'm working on an application that requires a great deal of stastical processing and output as images in a .net desktop application. The problems, including generating the output images, seem like a natural fit for R http://www.r-project.org/
Is there a wrapper, API, SDK, or port that will allow me to call R from .net?
For array, matrix and object indices, R is a 1-based language, rather than 0-based like the C# language.
So in conclusion: while R itself is mostly written in C (with hefty chunks in R and Fortran), R packages are mostly written in R (with hefty chunks written in C/C++).
R is a great language, but it can't do everything well. Thus, it is sometimes desirable to call code written in other languages from R. Conversely, when working in other great languages, you may encounter tasks that could be better done in R.
R uses several standard tools to enhance statistical models and conduct data analysis, but it is also efficient for software development. Developers can create various applications using an interactive web application package such as R Shiny. R programming is also used in developing statistical software applications.
R.NET is pretty buggy with the newer version of R. And if it doesn't work right, it works terribly (and will continue to do so unless you know exactly how to fix it).
Personally, I'd recommend using R script files and executing them. What you should do is start your R script with
> sink() > #set your working directory here with setwd() > #your code comes in here > sink(#name your output file here - could label it with a .txt if you please + )
And from .NET, you have to include the System.Diagnostics namespace by typing using System.Diagnostics
and then write this code:
string strCmdLine; strCmdLine = "R CMD BATCH" + /* the path to your R script goes here */; System.Diagnostics.Process.Start("CMD.exe",strCmdLine); process1.Close();
You can then use a StreamReader like this:
StreamReader ROutput = new StreamReader(/* your R output file's path should go here */)
And then parse it as you please (see RegEx and a string's split method if you need help with that too).
Hope this helps!
I found this library easier to use:
http://rdotnet.codeplex.com/
Some reasons why:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With