sts_animate | R Documentation |
The animate
-method for sts
objects
iterates over time points, plotting maps of the current|cumulative
counts|incidence via stsplot_space
, optionally
including a time series chart below the map to track the epidemic curve.
It is worth using functionality of the animation package
(e.g., saveHTML
) to directly export the
animation into a useful format.
## S3 method for class 'sts'
animate(object, tps = NULL, cumulative = FALSE,
population = NULL, at = 10, ...,
timeplot = list(pos = 1, size = 0.3, fill = TRUE),
sleep = 0.5, verbose = interactive(), draw = TRUE)
object |
an object of class |
tps |
a numeric vector of one or more time points at which to plot the map.
The default |
cumulative |
logical specifying if the cumulative counts/incidence over time
should be plotted. The cumulative incidence is relative to the
population from the first time point |
population , at , ... |
arguments for |
timeplot |
if a list and package gridExtra is available,
a time series chart of the counts along
the selected time points |
sleep |
time to wait ( |
verbose |
logical indicating if a |
draw |
logical indicating if the produced plots at each time point should
be drawn directly (the default) or not.
The setting |
(invisibly) a list of the length(tps)
sequential plot objects.
These are of class "gtable"
(from gtable)
if the timeplot
is included, otherwise of class
"\code{trellis"
.
Sebastian Meyer
the other plot types documented in stsplot
for static
time series plots and maps.
data("measlesWeserEms")
## animate the weekly counts of measles (during weeks 12-16 only, for speed)
if (interactive() && require("animation")) {
oldwd <- setwd(tempdir()) # to not clutter up the current working dir
saveHTML(animate(measlesWeserEms, tps=12:16),
title="Evolution of the measles epidemic in the Weser-Ems region",
ani.width=500, ani.height=600)
setwd(oldwd)
}
## Not run:
## animate the weekly incidence of measles (per 100'000 inhabitants),
## and label the time series plot with dates in a specified format
animate(measlesWeserEms, tps=12:16,
population = measlesWeserEms@map$POPULATION / 100000,
timeplot = list(as.Date = TRUE,
scales = list(x = list(format = "%G/%V"))))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.