I want to build a plot faceted by region where the y-axis is the number of cases in the region and the 2nd y-axis is the number of cases per 100k population.
Since each region has a different population the transformation would be different for each region.
Can I do that with sec.axis() ?
Basically this, but I want to add a secondary y-axis that shows the number of cases per 100k given that Ontario's population is 12M and Quebec's population is 8M (so divide cases by population then multiply by 100k)
cases <- tibble::tribble(
~province, ~date_report, ~avg_cases_last7,
"Ontario", "2020-08-26", 111,
"Quebec", "2020-08-26", 89.8571428571429,
"Ontario", "2020-08-27", 116.857142857143,
"Quebec", "2020-08-27", 93.4285714285714,
"Ontario", "2020-08-28", 113.142857142857,
"Quebec", "2020-08-28", 89.8571428571429,
"Ontario", "2020-08-29", 118.285714285714,
"Quebec", "2020-08-29", 90.4285714285714,
"Ontario", "2020-08-30", 117.714285714286,
"Quebec", "2020-08-30", 97,
"Ontario", "2020-08-31", 117.571428571429,
"Quebec", "2020-08-31", 107.285714285714,
"Ontario", "2020-09-01", 124.571428571429,
"Quebec", "2020-09-01", 115.857142857143,
"Ontario", "2020-09-02", 126.714285714286,
"Quebec", "2020-09-02", 114.428571428571,
"Ontario", "2020-09-03", 128.428571428571,
"Quebec", "2020-09-03", 125.285714285714,
"Ontario", "2020-09-04", 130.142857142857,
"Quebec", "2020-09-04", 141.857142857143,
"Ontario", "2020-09-05", 136.285714285714,
"Quebec", "2020-09-05", 151.428571428571
) %>%
mutate(date_report = as.Date(date_report))
ggplot(cases, aes(x= date_report, y = avg_cases_last7)) +
geom_line() +
facet_wrap(~province, scales = "free")

