Project Description: R.NET is an in-process interoperability bridge to R from the .NET Framework. R.NET requires .NET Framework 4 and the native R DLLs installed with the R environment. R.NET works on Windows, Linux and MacOS.
To get started you should now head for the
R.NET documentation on GiHub pages. The
documentation on this Codeplex site is now legacy.
R.NET is now distributed via
R.NET.Community on NuGet
News
2015-08-09:
- Moved the documentation to R.NET documentation on GiHub pages. Over the coming weeks it will have a growing list of howto and troubleshooting pages to facilitate user support, since many issues reported e.g. via stackoverflow are related.
- Recently released R.NET 1.6.5.
- Working on a new release of rClr rClr
2014-12-18 Release of the R package rClr 0.7-2 at
rClr. This is a significant release due to the fact that all unit tests that can pass using Mono indeed pass.
2014-11-16 R.NET source code reference repository
is now hosted on GitHub. This has been requested by several contributors amongst other things to facilitate pull requests.
2014-06-17 Thanks to
Evelina Gabasova for documenting
Setting up R.NET on Mac
Known Issues
- There are persisting issues running R.NET from an ASP.NET application. Most issues can be worked around, but need clear documentation.
Whetting the appetite
Program.cs
using System;
using System.Linq;
using RDotNet;
namespace Sample1
{
class Program
{
static void 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(new double[] { 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#.