animate
-method for sts
objects
supersedes the stsplot
type observed~1|unit*time
implemented by the function stsplot_spacetime
.
Maps generated by stsplot_space
are
sequentially plotted along time (optionally showing cumulative
counts), with an optional time series chart below the map to track the
epidemic curve.
It is worth using functionality of the saveHTML
) to directly export the
animation into a useful format.
See Meyer and Held (2014, Supplement A) for an example with the
fluBYBW
data.## S3 method for class 'sts':
animate(object, tps = NULL, cumulative = FALSE,
population = NULL, at = 10, ...,
timeplot = list(height = 0.3),
sleep = 0.5, verbose = interactive(), draw = TRUE)
"sts "
or a matrix of counts,
i.e., observed(stsObj)
, where especially
colnames(x)
have to be contained in row.names(map)
.
If a matrix, the
tps=NULL
means the whole time period 1:nrow(object)
.stsplot_space
.stsplot_timeSimple
) and package tps
will be plotted below the map.
Sys.sleep
) between subsequent snapshots (only if
dev.interactive
), in seconds.txtProgressBar
should be shown
during generation of the animation -- which may take a while.
Default is to do so in interacti
draw = FALSE
is useful if one would like to
manually arrange the plots, which are always returned invisibly in length(tps)
sequential plot objects
of class "gtable
"
(if the the timeplot
is active) or of class
"trellis"
(otherwise).
[object Object]
stsplot
for static
time series plots and maps.
## sequential plot of the counts by region in weeks 12-16 only (for speed) if (require("animation")) { oldwd <- setwd(tempdir()) # to not clutter up the current working dir saveHTML(animate(measlesWeserEms, tps=12:16, cumulative=FALSE), title="Evolution of the measles epidemic in the Weser-Ems region", ani.width=500, ani.height=600) setwd(oldwd) }