R/sample.host.id.with.hist.R

Defines functions sample.host.id.with.hist

sample.host.id.with.hist <-
  function(net, size, hist){
    hist.set <- unique(net %v% "infection_history")
    if (!is.element(hist, hist.set)){
      stop("There are no hosts with history HIST")
    }
    pool <- which(net %v% "infection_history" %in% hist)
    if(length(pool)==1)
      return(rep(pool, size))
    else{
      return(sample(pool, size=size, replace=TRUE))
    }
}

Try the epinetics package in your browser

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

epinetics documentation built on May 2, 2019, 6:25 p.m.