I'm looking to use R.NET to execute an existing R script but haven't had success. Is this actually possible? I've run the example code successfully, so my basic setup is ok.
My code looks like the following:
static void RTest()
{
var envPath = Environment.GetEnvironmentVariable("PATH");
var rBinPath = System.Environment.Is64BitProcess ? @"C:\Program Files\R\R-3.0.1\bin\x64" : @"C:\Program Files\R\R-3.0.1\bin\i386";
Environment.SetEnvironmentVariable("PATH", envPath + Path.PathSeparator + rBinPath);
using( var engine = REngine.CreateInstance("RDotNet") )
{
engine.Initialize();
using( var fs = File.OpenRead(@"C:\R-scripts\r-test.R") )
{
engine.Evaluate(fs);
}
}
}
Which I'm running in a console app for testing (eventually I want to have it run server-side in a web app).
The r-test.R script works when run in RStudio so there's no problem there and should result in writing a csv file to disk. I do see some 'Loading required package' messages being output to the console so something is working but the resultant csv file does not appear.