Skip to contents

Operators acting on objects to extract or replace parts.

Usage

# S4 method for MCMC
[(x, i, j, ..., drop = TRUE)

# S4 method for PhasesMCMC
[(x, i, j, ..., drop = TRUE)

# S4 method for MCMC,numeric,missing
[[(x, i)

# S4 method for PhasesMCMC,numeric,missing
[[(x, i)

# S4 method for PhasesMCMC,character,missing
[[(x, i)

# S4 method for MCMC
[(x, i, j, ...) <- value

# S4 method for PhasesMCMC
[(x, i, j, ...) <- value

Arguments

x

An object from which to extract element(s) or in which to replace element(s).

i, j

Indices specifying elements to extract or replace.

...

Currently not used.

drop

A logical scalar: should the result be coerced to the lowest possible dimension? This only works for extracting elements, not for the replacement.

value

A possible value for the element(s) of x.

Value

A subsetted object.

See also

Other mutators: bind, mutator, sort()

Author

N. Frerebeau

Examples

## Events
(eve <- as_events(events, calendar = "CE", iteration = 1))
#> <EventsMCMC>
#> - Number of events: 4
#> - Time scale: CE

eve[1:1000, ] # Select the first 1000 iterations
#> <EventsMCMC>
#> - Number of events: 4
#> - Time scale: CE
eve[, 1:2]    # Select the first 2 events
#> <EventsMCMC>
#> - Number of events: 2
#> - Time scale: CE

cbind2(eve[, 1:2], eve[, 3:4]) # Combine two MCMC objects
#> <MCMC>
#> - Number of events: 4
#> - Time scale: CE
sort(eve, decreasing = TRUE)   # Sort events in descending order
#> <EventsMCMC>
#> - Number of events: 4
#> - Time scale: CE

## Phases
(pha <- as_phases(phases, start = c(1, 3), calendar = "CE", iteration = 1))
#> <PhasesMCMC>
#> - Number of phases: 2
#> - Time scale: CE

pha[1:1000, , ]          # Select the first 1000 iterations
#> <PhasesMCMC>
#> - Number of phases: 2
#> - Time scale: CE
pha[, 1, , drop = FALSE] # Select the first phase
#> <PhasesMCMC>
#> - Number of phases: 1
#> - Time scale: CE