data("imdepi")
imdepiB <- subset(imdepi, type == "B")
# Animate the first year of type B with a step size of 7 days
animate(imdepiB, interval=c(0,365), time.spacing=7, nmax=Inf, sleep=0.1)
# Sequential animation of type B events during the first year
animate(imdepiB, interval=c(0,365), time.spacing=NULL, sleep=0.1)
# Animate the whole time range but with nmax=60 snapshots only
animate(imdepiB, time.spacing=NA, nmax=60, sleep=0.1)
# Such an animation can be saved in various ways using the tools of
# the animation package, e.g., saveHTML()
if (require("animation")) {
saveHTML(animate(imdepiB, interval=c(0,365), time.spacing=7),
outdir = tempdir(), htmlfile = "imdepi_animation.html",
nmax = Inf, interval = 0.2, loop = FALSE,
title = "Animation of the first year of type B events")
}
Run the code above in your browser using DataLab