sequence.extract: Extract and replace elements of a sequence

sequence.extractR Documentation

Extract and replace elements of a sequence

Description

The array accessor generics allow extracting and replacing scenarios within am existing sequence. [ and [[ work identical to

Usage

## S4 method for signature 'ScenarioSequence,numeric,missing,missing'
x[i]

## S4 method for signature 'ScenarioSequence,numeric'
x[[i]]

## S4 replacement method for signature 'ScenarioSequence,numeric,missing,EffectScenario'
x[[i, j]] <- value

## S4 method for signature 'ScenarioSequence'
length(x)

Arguments

x

sequence

i

index of elements to extract or replace

j

not used

value

new scenario

Value

various

Functions

  • x[i: Returns a list of scenarios from the sequence.

  • x[[i: Returns a single scenario from the sequence.

  • `[[`(x = ScenarioSequence, i = numeric, j = missing) <- value: Replaces a single scenario in the sequence.

  • length(ScenarioSequence): Returns the number of scenarios in the sequence.

Examples

# create a sequence
seq <- sequence(list(minnow_it, minnow_it), breaks=3)

seq[1]       # first element, as a list of scenarios
seq[c(1)]    # the same
seq[c(1, 2)] # both elements as a list of scenarios
seq[[1]]     # first element as a scenario

# replacing single elements
seq[[1]] <- minnow_sd %>% set_times(1:3)

cvasi documentation built on Sept. 11, 2025, 5:11 p.m.