Code for replicating some ONS Publications
Source:vignettes/Replicating_ONS_Publications.Rmd
Replicating_ONS_Publications.Rmd
As part of the QA checks for this package there is code to replicate official ONS publications.
Salary
EARN06
earn06 <- lfs %>%
dplyr::filter(FTPTWK == "Full-time") %>%
dplyr::filter(!is.na(OCCUPATION_MAJOR)) %>%
lfs_summarise_salary(QUARTER, OCCUPATION_MAJOR) %>%
tidyr::pivot_wider(
id_cols = QUARTER,
names_from = OCCUPATION_MAJOR,
values_from = "mean_weekly_pay"
)
EARN07
Currently only accurate from 2009 onwards
earn07 <- lfs %>%
dplyr::filter(YEAR > 2009) %>%
dplyr::filter(!is.na(INDUSTRY)) %>%
dplyr::mutate(GROUPED_INDUSTRY = dplyr::case_when(
substr(INDUSTRY, 1, 1) == "A" ~ "A",
substr(INDUSTRY, 1, 1) %in% c("B", "D", "E") ~ "BDE",
substr(INDUSTRY, 1, 1) %in% "C" ~ "C",
substr(INDUSTRY, 1, 1) %in% "F" ~ "F",
substr(INDUSTRY, 1, 1) %in% "G" ~ "G",
substr(INDUSTRY, 1, 1) %in% "H" ~ "H",
substr(INDUSTRY, 1, 1) %in% "I" ~ "I",
substr(INDUSTRY, 1, 1) %in% "J" ~ "J",
substr(INDUSTRY, 1, 1) %in% c("K", "L") ~ "KL",
substr(INDUSTRY, 1, 1) %in% "M" ~ "M",
substr(INDUSTRY, 1, 1) %in% "N" ~ "N",
substr(INDUSTRY, 1, 1) %in% "O" ~ "O",
substr(INDUSTRY, 1, 1) %in% "P" ~ "P",
substr(INDUSTRY, 1, 1) %in% "Q" ~ "Q",
substr(INDUSTRY, 1, 1) %in% c("R", "S", "T") ~ "RST"
# substr(INDUSTRY, 1, 1) %in% "U" ~ "U"
)) %>%
dplyr::filter(!is.na(GROUPED_INDUSTRY)) %>%
dplyr::filter(FTPTWK == "Full-time") %>%
lfs_summarise_salary(QUARTER, GROUPED_INDUSTRY) %>%
tidyr::pivot_wider(
id_cols = QUARTER,
names_from = GROUPED_INDUSTRY,
values_from = "mean_weekly_pay"
)
Unemployment
Hours Worked
HOUR01 NSA
hour01 <- lfs %>%
dplyr::mutate(FT = !FTPTWK == "Full-time") %>%
lfs_summarise_hours(QUARTER, FT) %>%
tidyr::pivot_wider(
id_cols = QUARTER,
names_from = FT,
values_from = hours
)