Learn R Programming

lmForc (version 1.0.0)

subset_identical: Subset a list of Forecast objects to identical origin or future values.

Description

Function for subsetting all forecasts in a list of Forecast objects to overlapping origin or future values.

Usage

subset_identical(forcs, slot)

Value

List of subsetted Forecast objects with identical future or origin values.

Arguments

forcs

List of Forecast objects.

slot

Character representing whether the list of Forecasts will be subset to identical origin or future values. Must be either "origin" or "future".

Examples

Run this code

forc1_1h <- Forecast(
  origin = as.Date(c("2010-02-17", "2010-05-14", "2010-07-22", "2010-12-05", "2011-03-10")),
  future = as.Date(c("2010-06-30", "2010-09-30", "2010-12-31", "2011-03-31", "2011-06-30")),
  forecast = c(4.27, 3.36, 4.78, 5.45, 5.12),
  realized = c(4.96, 4.17, 4.26, 4.99, 5.38),
  h_ahead = 1
)

forc2_1h <- Forecast(
  origin = as.Date(c("2010-02-17", "2010-05-14", "2010-07-22", "2010-12-22", "2011-03-27")),
  future = as.Date(c("2010-06-30", "2010-09-30", "2010-12-31", "2011-03-31", "2011-06-30")),
  forecast = c(4.01, 3.89, 3.31, 4.33, 4.61),
  realized = c(4.96, 4.17, 4.26, 4.99, 5.38),
  h_ahead = 1
)

forcs <- list(forc1_1h, forc2_1h)

subset_identical(forcs, slot = "origin")

Run the code above in your browser using DataLab