# Reproduce Fig 4.5 (right upper panel), p. 68
# NB: This figure will look different to that of in the book, since we
# believe that the original authors has made some errors in specifying
# the sample size of the dots.
library(dplyr)
df <- parvob19_ew_1996 %>%
mutate(age = round(age)) %>%
group_by(age) %>%
summarise(pos = sum(seropositive), tot = n())
plot(df$age, df$pos / df$tot,
cex = 0.02 * df$tot, pch = 16, xlab = "age", ylab = "seroprevalence",
xlim = c(0, 82), ylim = c(0, 1)
)
Run the code above in your browser using DataLab