Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

stsXtrct

Subsetting "sts" Objects


Description

The [-method extracts parts of an "sts" object using row (time) and column (unit) indices.

Usage

## S4 method for signature 'sts'
x[i, j, ..., drop]

Arguments

x

an object of class "sts".

i

row index (integer or logical vector).

j

column index (character, integer, or logical vector).

...,drop

unused (arguments of the generic).
Dimensions are never dropped.

Details

Row indices are used to select a subset of the original time period. The start and epoch slots of the time series are adjusted accordingly. A warning is issued if an irregular integer sequence is used to extract rows, e.g., x[c(1,2,4),], which could destroy the structure of the time series (freq).

Column indices work as usual when indexing matrices, so may select units by name, position or a vector of booleans. When subsetting columns, population fractions are recomputed if and only if x is no multinomialTS and already contains population fractions.

NA indices are not supported, negative indices are.

Note that a [<- method (i.e., subassignment) is not implemented.

Value

an object of class "sts".

Examples

data("ha.sts")
haagg <- aggregate(ha.sts, nfreq=13)

plot(haagg[, 3])       # Single series
plot(haagg[1:30, 3])   # Somewhat shorter

#Counts at time 20
plot(haagg[20, ], type = observed ~ unit)

surveillance

Temporal and Spatio-Temporal Modeling and Monitoring of Epidemic Phenomena

v1.19.1
GPL-2
Authors
Michael H<f6>hle [aut, ths] (<https://orcid.org/0000-0002-0423-6702>), Sebastian Meyer [aut, cre] (<https://orcid.org/0000-0002-1791-9449>), Michaela Paul [aut], Leonhard Held [ctb, ths], Howard Burkom [ctb], Thais Correa [ctb], Mathias Hofmann [ctb], Christian Lang [ctb], Juliane Manitz [ctb], Andrea Riebler [ctb], Daniel Saban<e9>s Bov<e9> [ctb], Ma<eb>lle Salmon [ctb], Dirk Schumacher [ctb], Stefan Steiner [ctb], Mikko Virtanen [ctb], Wei Wei [ctb], Valentin Wimmer [ctb], R Core Team [ctb] (A few code segments are modified versions of code from base R)
Initial release
2021-03-30

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.