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

New Post: Could not load file or assembly 'RDotNet, Version=1.5.4.0

$
0
0
Hello.

I'm a new C# user trying to get R.NET working in Linux. I just copied one of the examples from this page to see if it works, but I think I am making some mistakes on setting the directories because I keep getting this error:
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'RDotNet, Version=1.5.4.0, Culture=neutral, PublicKeyToken=5f72f6e23c6920d4' or one of its dependencies.
File name: 'RDotNet, Version=1.5.4.0, Culture=neutral, PublicKeyToken=5f72f6e23c6920d4'
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not load file or assembly 'RDotNet, Version=1.5.4.0, Culture=neutral, PublicKeyToken=5f72f6e23c6920d4' or one of its dependencies.
File name: 'RDotNet, Version=1.5.4.0, Culture=neutral, PublicKeyToken=5f72f6e23c6920d4'
Any advice? Here is the original code exactly:
using System;
using System.IO;
using System.Linq;
using RDotNet;

class Program
{

    static void Main(string[] args)
    {
          string PATH = @"/home/parker/.R.NET";
          // Set the folder in which R.dll locates.
          var envPath = Environment.GetEnvironmentVariable(PATH);
          var rBinPath = @"/usr/lib/R/lib";
            var R_HOME = @"/usr/lib/R";
          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);
          }
    }
}
I compiled using this command:
dmcs /reference:/home/parker/.R.NET/RDotNet Rtest.cs

Viewing all articles
Browse latest Browse all 1634

Trending Articles



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