This project is read-only.

How can i load a package like forecast?

Jul 21, 2015 at 1:35 PM
Edited Jul 21, 2015 at 3:39 PM
Hi there,

I am trying to use engine.Evaluate("install.packages('forecast', .Library)");
 engine.Evaluate("dataset = read.table(file.choose(),skip=1)");

                     engine.Evaluate(@"install.packages('forecast')");
                    engine.Evaluate("require('forecast')");
                    engine.Evaluate("library('forecast')");

engine.Evaluate("z1 <- ts(dataset,frequency = 15, start=c(2010,11))"); 
                    engine.Evaluate("forecastA <- HoltWinters(z1)");
                    engine.Evaluate("forecast2 <- forecast.HoltWinters(z1,h=6)");
                    engine.Evaluate("plot(forecastA)");
                    engine.Evaluate("plot.forecast(forecast2)");
but it says Error in object$x : $ operator is invalid for atomic vectors
Feb 20, 2016 at 1:12 AM
not sure exactly where your code is throwing the error.
But typically when i'm not sure if a package is installed or not I use the following check.

rengine.Evaluate("if("fastcluster" %in% rownames(installed.packages()) == FALSE) {install.packages("fastcluster")}");
rengine.Evaluate("library(fastcluster)");

Granted, I'm wanting to make sure that the fastcluster package is installed. Change fastcluster to forecast for your case.