Including vax

knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

We begin with a blank SEIIAR data.table:

library(data.table)
print(spread::norway_seiiar_noinfected_2017)

We then take a vax data.table that has the proportion of vaccinated people for each location_code:

vax_measles <- fhidata::norway_childhood_vax[
  year==2016 & 
  stringr::str_detect(location_code,"^municip") & 
  vax=="measles",
  c("location_code","proportion")
  ]

print(vax_measles)

We then use the function convert_blank_seiiar_with_vax to combine the two:

norway_seiiar_measles_noinfected_2017 <- spread::convert_blank_seiiar_with_vax(
  seiiar = spread::norway_seiiar_noinfected_2017, 
  vax = vax_measles
  )

We now have a data.table that contains "recovered" people (i.e. vaccinated people):

print(norway_seiiar_measles_noinfected_2017)

We can then add some infected people:

norway_seiiar_measles_oslo_2017 <- copy(norway_seiiar_measles_noinfected_2017)
norway_seiiar_measles_oslo_2017[location_code == "municip0301", I := 10]
norway_seiiar_measles_oslo_2017[location_code == "municip0301", S := S - I]

print(norway_seiiar_measles_oslo_2017[location_code=="municip0301"])  


Try the spread package in your browser

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

spread documentation built on Aug. 20, 2019, 5:13 p.m.