data("imdepi")
imdepiB <- subset(imdepi, type == "B")
if (FALSE) {
# 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=20 snapshots only
animate(imdepiB, time.spacing=NA, nmax=20, sleep=0.1)
}
# Such an animation can be saved in various ways using the tools of
# the animation package, e.g., saveHTML()
if (interactive() && require("animation")) {
oldwd <- setwd(tempdir()) # to not clutter up the current working dir
saveHTML(animate(imdepiB, interval = c(0,365), time.spacing = 7),
nmax = Inf, interval = 0.2, loop = FALSE,
title = "Animation of the first year of type B events")
setwd(oldwd)
}
Run the code above in your browser using DataLab