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

stsplot_spacetime

Map of Disease Incidence


Description

For each period (row) or for the overall period of the observed matrix of the "sts" object, a map showing the counts by region is produced. It is possible to redirect the output into files, e.g., to generate an animated GIF.

Usage

stsplot_spacetime(x, type, legend = NULL, opts.col = NULL, labels = TRUE,
                  wait.ms = 250, cex.lab = 0.7, verbose = FALSE,
                  dev.printer = NULL, ...)

Arguments

x

an object of class "sts".

type

a formula (see stsplot). For a map aggregated over time (no animation), use observed ~ 1 | unit, otherwise observed ~ 1 | unit * time.

legend

An object of type list containing the following items used for coloring

  • dxposition increments in x direction

  • dyposition increments in y direction

  • xposition in x

  • yposition in y

  • onceBoolean - if TRUE then only shown once

If NULL then a default legend is used.

opts.col

A list containing the two elements

  • ncolorsNumber of colors to use for plotting

  • use.colorBoolean if TRUE then colors will be used in the palette, otherwise grayscale

labels

Boolean whether to add labels

wait.ms

Number of milliseconds to wait between each plot

cex.lab

cex of the labels

verbose

Boolean whether to write out extra information

dev.printer

Either NULL (default), which means that plotting is only to the screen, or a list with elements device, extension, width, height, and name (with defaults png, ".png", 640, 480, and "Rplot", respectively) to dev.print the plots to files (only works in interactive sessions). This option is more or less obsolete since the animation package provides better features for output to files.

...

Extra arguments sent to the plot function.

Note

The animate.sts method provides a re-implementation and supersedes this function!

Author(s)

Michael Höhle

See Also

Other stsplot types, and animate.sts for the new implementation.

Examples

data("ha.sts")
print(ha.sts)

## map of total counts by district
plot(ha.sts, type=observed ~ 1 | unit)
## only show a sub-period total for two selected districts
plot(ha.sts[1:20,1:2], type=observed ~ 1 | unit)

## Not run: 
# space-time animation
plot(aggregate(ha.sts,nfreq=13), type= observed ~ 1 | unit * time)

#print the frames to a png device
#and do the animation without extra sleeping between frames
imgname <- file.path(tempdir(), "berlin")
plot(aggregate(ha.sts,nfreq=13), type = observed ~ 1 | unit * time,
     wait.ms=0, dev.printer=list(name=imgname))

#Use ImageMagick (you might have to adjust the path to 'convert')
system(paste0("convert -delay 50 ", imgname,
              "*.png ", imgname, "-animated.gif"))

## End(Not run)

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.