diff --git a/NEWS.md b/NEWS.md index e64c10e..78a7b92 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,7 @@ # socialmixr (development version) * The speed of loading surveys has been increased. +* An error has been fixed causing NA contact matrices if any 5-year age band in the population data was missing. # socialmixr 0.3.2 diff --git a/R/contact_matrix.r b/R/contact_matrix.r index 4fa600d..3053455 100644 --- a/R/contact_matrix.r +++ b/R/contact_matrix.r @@ -430,6 +430,8 @@ contact_matrix <- function(survey, countries = NULL, survey.pop, age.limits, fil # add upper.age.limit after sorting the survey.pop ages (and add maximum age > given ages) survey.pop <- survey.pop[order(lower.age.limit), ] + # if any lower age limits are missing remove them + survey.pop <- survey.pop[!is.na(population)] survey.pop$upper.age.limit <- unlist(c( survey.pop[-1, "lower.age.limit"], 1 + max(