Project Description: R.NET enables the .NET Framework to interoperate with the R statistical language in the same process. R.NET requires .NET Framework 4 and the native R DLLs installed with the R environment. R.NET works on Windows, Linux and MacOS. Enjoy statistics and programming in your special language with R.
You should head for the documentation to get started with R.NET.
2014-04-20 Version 1.5.10 is released on this site. This is a major upgrade from 1.5.5 (despite the numbering), with many new features, improvements and fixes. While it is tagged beta, it is backed by unit testing and you are encouraged to use it now and give feedback. There are a couple of API changes that will break the compilation of previous code R.NET: this is however a matter of minutes to fix it. This API change is necessary to increase the robustness of R.NET, given some limitations of the native R engine.
R.NET 1.5.5 and related packages remain available:
Program.cs
You should head for the documentation to get started with R.NET.
News
2014-04-24 Version 1.5.11.2014-04-20 Version 1.5.10 is released on this site. This is a major upgrade from 1.5.5 (despite the numbering), with many new features, improvements and fixes. While it is tagged beta, it is backed by unit testing and you are encouraged to use it now and give feedback. There are a couple of API changes that will break the compilation of previous code R.NET: this is however a matter of minutes to fix it. This API change is necessary to increase the robustness of R.NET, given some limitations of the native R engine.
NuGet Packages
You will find NuGet packages for R.NET 1.5.11 and R.NET.FSharp 0.1.4 at this download page on this site. They are not uploaded at the public NuGet gallery. You can still use these packages if you set up a local feed. Further instructions are in the documentation.R.NET 1.5.5 and related packages remain available:
- R.NET released on NuGet Gallery (only Windows version). Just type "Install-Package R.NET" to install it.
- F# specific package, RDotNet.FSharp
- an alpha-release graphics engine package, RDotNet.Graphics.
Known Issues
- There are persisting issues running R.NET from an ASP.NET application. The exact cause remains unclear, but this may be a inherent limitation of the R native engine with respect to thread safety.
- Custom startup parameters when initializing the engine are ignored on Windows. The main drawback is memory limitations to 2GB. There will be at least a partial workaround for the next version.
Whetting the appetite
- The example below gives a flavour of how R.NET works from C#. You should head for the documentation to really get started with R.NET. Examples of programming styles mixing C# and R are also available at the Examples page.
Program.cs
using System; using System.Linq; using RDotNet; namespace Sample1 { class Program { staticvoid Main(string[] args) { REngine.SetEnvironmentVariables(); // There are several options to initialize the engine, but by default the following suffice: REngine engine = REngine.GetInstance(); // .NET Framework array to R vector. NumericVector group1 = engine.CreateNumericVector(newdouble[] { 30.02, 29.99, 30.11, 29.97, 30.01, 29.99 }); engine.SetSymbol("group1", group1); // Direct parsing from R script. 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. GenericVector testResult = engine.Evaluate("t.test(group1, group2)").AsList(); double p = testResult["p.value"].AsNumeric().First(); Console.WriteLine("Group1: [{0}]", string.Join(", ", group1)); Console.WriteLine("Group2: [{0}]", string.Join(", ", group2)); Console.WriteLine("P-value = {0:0.000}", p); // you should always dispose of the REngine properly.// After disposing of the engine, you cannot reinitialize nor reuse it engine.Dispose(); } } }
Related Projects
- R to CLR: an R package to access .NET (CLR) objects from R, complementing R.NET. If you are looking to access .NET code from R interactively, you should consider this package.
- F# R Provider: an F# library that provides static typed functions exposed by R packages, using the type provider mechanism of F#.