knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
We provide access to a variety of different data sources in conmat
. Most of these are centred around Australian data, as the package was initially created for disease modelling work in Australia. The aim of this vignette is to give a quick tour of the data sources available in conmat
.
library(conmat)
We provide functions to clean up world population data from socialmixr
.
world_data <- socialmixr::wpp_age() head(world_data)
We can tidy the data up, filtering down to a specified location and year with the age_population
function:
nz_2015 <- age_population( data = world_data, location_col = country, location = "New Zealand", age_col = lower.age.limit, year_col = year, year = 2015 ) nz_2015
This returns a conmat_population
object, which is a data frame that knows which columns represent age
and population
information. This is useful for other modelling parts of the conmat
package.
We provide two functions to access LGA (Local Government Area), and state level population age data, which are provided in 5 year age bins from 0, 5, up to 85+. These data are conmat_population
tibbles, which means that they know which columns represent the age
and population
information. This means that functions inside of conmat
can work a bit smoother as we refer to these columns frequently.
abs_age_lga()
fairfield <- abs_age_lga(lga_name = "Fairfield (C)") fairfield
Note that this is a conmat_population
object, which prints in red at the top of the data frame. This provides the information on the age
and population
columns, stating: age: lower.age.limit
, and population: population
, indicating which columns refer to the appropriate variables.
Also note that abs_age_lga
requires you to know the exact name of the LGA, you can see them in the dataset, abs_lga_lookup
abs_lga_lookup
And if you're not sure about a particular name of a place, you can use agrep
and filter
, to match on similar-ish characters, like so:
library(dplyr) abs_lga_lookup %>% filter(agrepl("Sydney", lga))
abs_age_state()
This takes in the abbreviated state names, and is also a conmat_population
object.
abs_age_state(state_name = "NSW")
You can see these state names with:
unique(abs_lga_lookup$state)
Note that "OT" stands for "other territories"
We provide other ABS data, listed now. You can read the full details of the data at their respective helpfiles, by writing, for example, ?abs_education_state
.
abs_education_state
abs_education_state_2020
abs_employ_age_lga
abs_household_lga
abs_pop_age_lga_2016
abs_pop_age_lga_2020
abs_state_age
A dataset containing data digitised from "The impact of SARS-CoV-2 vaccination on Alpha & Delta variant transmission", by David W Eyre, Donald Taylor, Mark Purver, David Chapman, Tom Fowler, Koen B Pouwels, A Sarah Walker, Tim EA Peto
eyre_transmission_probabilities
We can visualise the data like so:
library(ggplot2) library(stringr) library(dplyr) eyre_transmission_probabilities %>% group_by( setting, case_age_5y, contact_age_5y ) %>% summarise( across( probability, mean ), .groups = "drop" ) %>% rename( case_age = case_age_5y, contact_age = contact_age_5y ) %>% mutate( across( ends_with("age"), ~ factor(.x, levels = str_sort( unique(.x), numeric = TRUE ) ) ) ) %>% ggplot( aes( x = case_age, y = contact_age, fill = probability ) ) + facet_wrap(~setting) + geom_tile() + scale_fill_viridis_c() + coord_fixed() + theme_minimal() + theme( axis.text = element_text(angle = 45, hjust = 1) )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.