Learn R Programming

surveillance (version 1.5-4)

display-methods: Display Methods for Surveillance Time-Series Objects

Description

Display methods for objects of class "sts".

Arguments

Value

  • The methods are called for their side-effects.

Usage

plot(x,y,type,...) print(x,...)

Details

The plotting of time-series plots relies on two internal functions with plot.sts.time.one being the work-horse. Its arguments are (almost) similiar to plot.survRes. k is the column to plot.

plot.sts.time(x, type,method=x@control$name,disease=x@control$data,same.scale=TRUE, par.list=list(mfrow=magic.dim(nAreas),mar=par()$mar),...) plot.sts.time.one <- function(x, k=1, domany=FALSE,ylim=NULL,xaxis.years=TRUE, xaxis.units=TRUE, epochsAsDate=x@epochAsDate, xlab="time", ylab="No. infected", main=NULL, type="s",lty=c(1,1,2),col=c(NA,1,4),lwd=c(1,1,1), outbreak.symbol = list(pch=3, col=3, cex=1),alarm.symbol=list(pch=24, col=2, cex=1),cex=1,legend.opts=list(x="top", legend=NULL,lty=NULL,pch=NULL,col=NULL),dx.upperbound=0.5, hookFunc=function() {},...)

Note that the hookFunc is called after all the basic plotting has be done, i.e. it is not possible to control formatting with this function. For spacetime plots the following internal function does all the work:

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

Alarmplot plot.sts.alarm <- function(x, lvl=rep(1,nrow(x)), ylim=NULL,xaxis.years=TRUE, xaxis.units=TRUE, epochsAsDate=x@epochAsDate, xlab="time", main=NULL, type="hhs",lty=c(1,1,2),col=c(1,1,4), outbreak.symbol = list(pch=3, col=3, cex=1),alarm.symbol=list(pch=24, col=2, cex=1),cex=1,cex.yaxis=1,...)

print is the method for printing sts objects.

See Also

plot.survRes

Examples

Run this code
data("ha.sts")
print(ha.sts)
plot(ha.sts, type= observed ~ time)
plot(ha.sts, type= observed ~ time | unit)
plot(ha.sts, type= observed ~ 1 | unit)
plot(ha.sts[1:20,1:2], type= observed ~ 1 | unit)

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

#Configure a png device printer to save the frames
dev.printer <- list(device=png, extension=".png", width=640, height=480,
                    name=file.path(tempdir(),"berlin"))

#Do the animation (without extra sleeping time between frames)
plot(aggregate(ha.sts,nfreq=13), type = observed ~ 1 | unit * time,
     wait.ms=0, dev.printer=dev.printer)

#Use ImageMagick (you might have to adjust the path to 'convert')
system(paste("convert -delay 50 ",dev.printer$name,
           "*.png ", dev.printer$name, "-animated.gif",sep=""))

Run the code above in your browser using DataLab