I am using R.Net 1.5 to attempt a simple forecast using ARIMA. I tried with R 2.14 and R 2.15. I am using Visual Studio 2012 target .NET 4, although I also tried .NET 4.5 and Visual Studio 2010.
Here is a piece of code that I wrote:
string rhome = System.Environment.GetEnvironmentVariable("R_HOME");
if (string.IsNullOrEmpty(rhome))
rhome = @"C:\Program Files\R\R-2.14.0";
System.Environment.SetEnvironmentVariable("R_HOME", rhome);
System.Environment.SetEnvironmentVariable("PATH", System.Environment.GetEnvironmentVariable("PATH") + ";" + rhome + @"\bin\x64");
using (REngine engine = REngine.CreateInstance("RDotNet"))
{
engine.Initialize();
NumericVector testGroup = engine.CreateNumericVector(submissions);
engine.SetSymbol("testGroup", testGroup);
engine.Evaluate("testTs <- c(testGroup)");
NumericVector ts = engine.GetSymbol("testTs").AsNumeric();
engine.Evaluate("tsValue <- ts(testTs, frequency=1, start=c(2010, 1, 1))");
engine.Evaluate("library(forecast)");
engine.Evaluate("arimaFit <- auto.arima(tsValue)");
engine.Evaluate("fcast <- forecast(tsValue, h=36)");
engine.Evaluate("plot(fcast)");
NumericVector nv = engine.GetSymbol("fcast").AsNumeric();
An attempt to get a numeric vector failed. Here I get a few errors. The first is "Error: the object cannot be forced to type" double ", and the second is" Error: an access violation was detected - continue with caution "
GenericVector, RDotNet.SymbolicExpressions. , , , , ARIMA, . , , , .
script , , , , R.Net . , . R.Net , Revolution ( , ), genericvector .
GenericVector. , : DynamicVector .
GenericVector newVector = engine.GetSymbol("fcast").AsList();
foreach (var vector in newVector)
{
try
{
DynamicVector dv = vector.AsVector();
}
catch (Exception)
{
}