==========================================================================
Use R.NET (I installed mine from NuGet) and the following code in a new C# console app (which was copied with minor changes from http://rdotnet.codeplex.com/).
It will work when pointed at the 32-bit version of R v2.11.1, but it will not work when pointed at the 64-bit version of R v2.11.1 (as noted in the code below).
When I installed NuGet, it automatically added references to the current project: RDotNet
(RDotNet.dll) and RDotNet.NativeLIbrary
(RDotNet.NativeLibrary.dll). You’ll need these references in any new project.
Works under VS2012 (untested under VS2010, but will probably work).
Works when compiled for both “x32” and “All CPU” (under “Build..Configuration Manager” in VS2012).
// Call R from .NET. Advantage is that everything is in process.
// Tested on VS2012, will probably work on VS2010.
using System;
using System.IO;
using System.Linq;
using RDotNet;
class Program
{
static void Main(string[] args)
{
// Set the folder in which R.dll locates.
var envPath = Environment.GetEnvironmentVariable("PATH");
var rBinPath = @"C:\Program Files (x86)\R\R-2.11.1\bin";
//var rBinPath = @"C:\Program Files\R\R-2.11.1-x64\bin"; // Doesn't work ("DLL was not found.")
Environment.SetEnvironmentVariable("PATH", envPath + Path.PathSeparator + rBinPath);
using (REngine engine = REngine.CreateInstance("RDotNet"))
{
// Initializes settings.
engine.Initialize();
// .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);
}
}
}
by:Contango http://stackoverflow.com/questions/5377070/c-sharp-r-interface
================================================================
https://www.google.com/search?q=r+t.test&ie=utf-8&oe=utf-8
https://www.google.com/search?q=GenericVector+.First%28%29&ie=utf-8&oe=utf-8
https://www.google.com/search?q=GenericVector&ie=utf-8&oe=utf-8#q=GenericVector+c%23
https://dist.nuget.org/index.html
https://www.nuget.org/packages/R.NET.Community/
http://rdotnet.codeplex.com/releases/view/168164
http://rdotnet.codeplex.com/
http://stackoverflow.com/questions/5377070/c-sharp-r-interface
file:///C:/Program%20Files%20(x86)/R/(D)COM%20Server/doc/00Index.html
https://cran.r-project.org/contrib/extra/dcom/
http://www.codeproject.com/Articles/25819/The-R-Statistical-Language-and-C-NET-Foundations
http://www.inside-r.org/packages/cran/rcom/docs/installstatconnDCOM
http://www.inside-r.org/packages/cran/rcom/docs/installstatconnDCOM
http://homepage.univie.ac.at/erich.neuwirth/php/rcomwiki/doku.php?id=wiki:r_d_com_rcom_and_and_other_software_systems
http://www.meta-numerics.net/Pages/Specs.aspx
https://www.google.com/search?q=c%23+regress&ie=utf-8&oe=utf-8#q=R+regression+Significance+F
http://jmp75.github.io/rdotnet/tut_data_frame/
http://jmp75.github.io/rdotnet/
https://rdotnet.codeplex.com/
https://msdn.microsoft.com/en-us/magazine/mt238409.aspx
https://www.google.com/search?q=roger+pane&ie=utf-8&oe=utf-8#q=roger+peng+r
Stat in C# without R
http://www.meta-numerics.net/Samples/SampleCalculator.aspx
R (D)COM Server and RExcel
This package contains a DCOM server used to connect a client application (e.g. Microsoft Excel) with R.
R (D)COM Server provides a COM-Interface to R as well as various COM objects and Active X controls for your applications. Additionally, an Add-In for Microsoft Excel is provided to easily use R in Excel and create statistical applications with Excel as the main GUI. The main features of this package are:
-COM server for local and remote use of R
-transfer of data into/from R, including NA, NaN,…
-Active X Controls for text and graphics output
-Installation/Uninstallation
-Repository for R instances for shared and exclusive access
-Many Samples
-Excel Add-In
Is commercial now: http://sunsite.univie.ac.at/rcom.
Author(s)
Thomas Baier and Erich Neuwirth
===================================
meta numerics
library features include advanced functions, function analysis (solvers), statistics and data analysis, linear algebra, and Fourier transforms.
http://www.meta-numerics.net/Pages/Specs.aspx