Quantcast
Channel: R.NET
Viewing all articles
Browse latest Browse all 1634

New Post: R Engine is not initializing

$
0
0
Hi all.
I am new to R.NET so by following community discussions I tried to connect to R from C# using R.NET.
I have set correct dll path and it was fine.
but program is crashing while executing engine.Initialize();

My code is

static void Main(string[] args)
{

    var envPath = Environment.GetEnvironmentVariable("PATH");
    var rBinPath = @"C:\R-3.0.2\bin\i386";
    Environment.SetEnvironmentVariable("PATH", envPath + Path.PathSeparator + rBinPath);
    using (REngine engine = REngine.CreateInstance("RDotNet"))
    {

        engine.Initialize(); // CRASHING IN THIS LINE.

        NumericVector group1 = engine.CreateNumericVector(new double[] { 30.02, 29.99, 30.11, 29.97, 30.01, 29.99 });
        engine.SetSymbol("group1", group1);
        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);
        Console.ReadLine();
    }
}

I am using
OS - XP sp3 -32 bit
R-3.0.2
R.NET -1.5.5
.NET 4.0
Visual Studio 2010


Please help me to solve this issue.

Viewing all articles
Browse latest Browse all 1634

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>