R/addIndexCase.R

Defines functions addIndexCase

Documented in addIndexCase

#' Highlight index case at 40 Broad Street.
#'
#' @param cex Numeric. Size of point.
#' @param col Character. Color of point.
#' @param pch Numeric. Type of of point.
#' @param add.label Logical. Add text annotation: "40 Broad Street"
#' @param text.size Numeric. Size of text label.
#' @return Add base R point and (optionally) text to a graphics plot.
#' @export
#' @examples
#' segmentLocator("216-1")
#' addIndexCase()

addIndexCase <- function(cex = 2, col = "red", pch = 1, add.label = FALSE,
  text.size = 0.5) {

  index.case <- cholera::fatalities[cholera::fatalities$case == 32, ]

  if (add.label) {
    text(index.case$x, index.case$y, labels = "40 Broad\nStreet",
      cex = text.size)
  }

  points(index.case$x, index.case$y, col = col, cex = cex, pch = pch)
}

Try the cholera package in your browser

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

cholera documentation built on Aug. 28, 2019, 9:04 a.m.