Defines functions plotbreaks

Documented in plotbreaks

#' @title plotbreaks
#' @description Plots the cases data with a line whenever the forward simulation is seeded using the real data.
#' @param data Data frame with the cases vector.
#' @param threshold The epidemic threshold, i.e. the number of cases required to spark a new outbreak in the model.
plotbreaks <- function(data,threshold){
  t0s <- epitimes(data,threshold)$start
  ptsdat <- as.data.frame(cbind('t'=data$time[t0s],'cpts'=data$cases[t0s]))
  p <- ggplot()+
    geom_line(data=data, aes_string(x='time',y='cases'),colour='dodgerblue',size=1) +
    theme_bw() + theme(legend.position = "none") +
    xlab('time')+ylab('cases') +
    geom_vline(xintercept = data$time[t0s],linetype='dashed')


Try the tsiR package in your browser

Any scripts or data that you put into this service are public.

tsiR documentation built on Jan. 21, 2021, 1:06 a.m.