# Reproduce Fig 4.1 (upper right panel), p. 63
library(dplyr)
df <- hav_be_2002 %>%
group_by(age) %>%
summarise(pos = sum(seropositive), tot = n())
plot(
df$age, df$pos / df$tot,
pty = "s", cex = 0.06 * df$tot, pch = 16, xlab = "age",
ylab = "seroprevalence", xlim = c(0, 86), ylim = c(0, 1)
)
Run the code above in your browser using DataLab