newHorizon: Create a new object of class 'horizon'

View source: R/class-horizon.R

newHorizonR Documentation

Create a new object of class 'horizon'

Description

The function creates a new object of class 'horizon' that represents the planning horizon of the model/scenario.

Usage

newHorizon(
  period = NULL,
  intervals = NULL,
  mid_is_end = FALSE,
  mid_is_start = FALSE,
  force_BY_interval_to_1_year = TRUE,
  desc = NULL,
  name = NULL
)

## S4 method for signature 'horizon'
update(object, ..., warn_nodata = TRUE)

## S4 method for signature 'config'
setHorizon(obj, period, ...)

## S4 method for signature 'config'
update(object, ..., warn_nodata = TRUE)

Arguments

period

(optional) integer vector with a range or a sequence of years to define the full period of the model/scenario. If not provided, the range of 'intervals' will be used.

intervals

(optional) either data.frame or integer vector. The data.frame must have start, mid, and end columns with modeled interval. The vector will be considered as lengths of each modeled interval in period.

mid_is_end

logical, if TRUE, the mid-year will be set to the end of the interval.

mid_is_start

logical, if TRUE, the mid-year will be set to the start of the interval.

force_BY_interval_to_1_year

logical, if TRUE (default), the base-year (first) interval will be forced to one year.

desc

character. Description of the horizon object, for own references.

name

character. Name of the horizon object. Used to distinguish between different horizons in the model or scenario, including the automatic creation of the folder name for the model/scenario scripts.

horizon

a new horizon object to be set.

Value

An object of class 'horizon'

Examples

newHorizon(2020:2050)
newHorizon(2020:2030, desc = "One-year intervals")
newHorizon(2020:2030, c(1, 2, 5, 10), desc = "Different length intervals")
newHorizon(2020:2035, c(1, 2, 5, 5, 5))
newHorizon(2020:2050, c(1, 2, 5, 7, 1))

newHorizon(intervals = data.frame(
  start = c(2030, 2031, 2034),
  mid =   c(2030, 2032, 2037),
  end =   c(2030, 2033, 2040)),
  desc = "Explicit assignment of intervals via data.frame"
  )

newHorizon(period = 2020:2050,
           intervals = data.frame(
             start = c(2030, 2031, 2034),
             mid =   c(2030, 2032, 2037),
             end =   c(2030, 2033, 2040)),
             desc = "The period will be trimmed to the scope of intervals")

newHorizon(2020:2050, c(3, 2, 5, 10),
           desc = "Pay attention to the length of the first interval")

newHorizon(period = 2020:2040,
           intervals = data.frame(
             start = c(2030, 2032, 2035),
             mid =   c(2031, 2033, 2037),
             end =   c(2032, 2034, 2040)))

olugovoy/energyRt documentation built on Nov. 21, 2024, 2:24 a.m.