display-methods         package:surveillance         R Documentation

_D_i_s_p_l_a_y _M_e_t_h_o_d_s _f_o_r _S_u_r_v_e_i_l_l_a_n_c_e _T_i_m_e-_S_e_r_i_e_s _O_b_j_e_c_t_s

_D_e_s_c_r_i_p_t_i_o_n:

     Display methods for objects of class '"sts"'.

_D_e_t_a_i_l_s:

     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.

_V_a_l_u_e:

     The methods are called for their side-effects.

_U_s_a_g_e:

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

_A_r_g_u_m_e_n_t_s:


     _x an object of class '"sts"'

     _y missing

     _t_y_p_e a formula specifying the plot type, several options are
          possible:

          '_o_b_s_e_r_v_e_d ~ _t_i_m_e' The observations in 'x' are aggregated over
               units and the resulting univariate time-series is
               plotted. The plotting is done by the function
               'plot.time.sts', which takes the same arguments as the
               'plot.survRes' function.

          '_o_b_s_e_r_v_e_d ~ _t_i_m_e | _u_n_i_t' shows 'dim(x)' plots with each
               showing the time-series of one observational unit. The
               actual plotting is done by the function 
               'plot.time.sts.one'

          '_o_b_s_e_r_v_e_d ~ _1 | _u_n_i_t' for each unit the counts are aggregated
               over time and a map illustrating the counts is shown.
               The column names of the 'x@observed' object are used to
               label the entries of the 'x@map'. Regions with an alarm
               are shaded.

          '_o_b_s_e_r_v_e_d ~ _1 | _u_n_i_t * _t_i_m_e' an animation consisting of
               'nrow(x)' frames is generated. Each frame contains the
               number of counts per region for the current row in the
               'observed' matrix. It is possible to redirect the output
               into files, e.g. to generate an animated GIF. See the
               examples.

          _c_o_d_e{_a_l_a_r_m ~ _t_i_m_e} Generates a so called alarmplot for a
               multivariate 'sts' object. For each time point and each
               series it is shown whether there is an alarm. In case of
               hierarchical surveillance the user can pass an
               additional argument 'lvl', which is a vector of the same
               length as rows in 'x' specifying for each time series
               its level.


     ... further arguments passed to or from other methods: in case of
          plotting these are passed to 'plot', in case of printing
          these are passed to 'print.default'

_S_e_e _A_l_s_o:

     'plot.survRes'

_E_x_a_m_p_l_e_s:

     data(ha)
     shp <- system.file("shapes/berlin.shp",package="surveillance")
     has4 <- disProg2sts(ha, map=readShapePoly(shp,IDvar="SNAME"))

     print(has4)
     plot(has4, type= observed ~ time)
     plot(has4, type= observed ~ time | unit)
     plot(has4, type= observed ~ 1 | unit)
     plot(has4[1:20,1:2], type= observed ~ 1 | unit)
     plot(aggregate(has4,nfreq=13), type= observed ~ 1 | unit * time)

     ## Not run: 
     #Configure a png device printer for the plot command
     dev.printer <-
     list(device=png,extension=".png",width=640,height=480,name="/tmp/berlin")

     #Do the animation
     plot(aggregate(has4,nfreq=13), type = observed ~ 1 | unit * time,
              dev.printer=dev.printer)

     #Use ImageMagick -- replace /sw/bin/convert by your path to convert
     system(paste("/sw/bin/convert -delay 50 ",dev.printer$name,
                "*.png /tmp/animated.gif",sep=""))
     ## End(Not run)

