improvements, updated report
[talweg.git] / R / getForecast.R
index fde8e45..c07be7c 100644 (file)
@@ -37,7 +37,7 @@
 #'   #do_something_with_pred
 #' }}
 #' @export
-getForecast = function(data, indices, forecaster, pjump,
+getForecast = function(data, indices, forecaster, pjump=NULL,
        memory=Inf, horizon=data$getStdHorizon(), ...)
 {
        # (basic) Arguments sanity checks
@@ -48,12 +48,16 @@ getForecast = function(data, indices, forecaster, pjump,
        if (any(indices<=0 | indices>data$getSize()))
                stop("Indices out of range")
        indices = sapply(indices, dateIndexToInteger, data)
-       if (!is.character(forecaster) || !is.character(pjump))
-               stop("forecaster and pjump should be of class character")
+       if (!is.character(forecaster))
+               stop("forecaster (name) should be of class character") #pjump could be NULL
 
        pred = list()
        forecaster = new(paste(forecaster,"Forecaster",sep=""), data=data,
-               pjump = getFromNamespace(paste("get",pjump,"JumpPredict",sep=""), "talweg"))
+               pjump =
+                       if (is.null(pjump))
+                               function() {}
+                       else
+                               getFromNamespace(paste("get",pjump,"JumpPredict",sep=""), "talweg"))
        for (today in indices)
        {
                pred[[length(pred)+1]] = list(