library(officedown) library(flextable) library(djprshiny) library(djprlabourdash) library(dplyr) library(dbplyr) knitr::opts_chunk$set( echo = FALSE, message = FALSE, error = FALSE, warning = FALSE, tab.topcaption = TRUE ) table_split <- function(tbl){ title <- tbl$caption$value tbl$caption <- NULL return(list(tbl = tbl, title = title)) } check_title <- function(table){ if(inherits(table$title, "data.frame")){ table$title <- table$title$txt } return(table) } ref_dates <- automate.labourforce.checks::reference_dates()
#dash_data <- get_dash_data() Sys.setenv("R_DJPRLABOURDASH_TABLEDEST" = "briefing")
Over the month of r ref_dates$reference_period
(unless otherwise stated):
df <- get_labourforce_db( c("A84423354L", "A84423349V", "A84423357V", "pt_emp_vic", "A84423350C", "A84423355R", "A84426256L", "A85223450L", "A85223451R", "A84424691V") ) df <- df %>% dplyr::filter(.data$series_id == "A84424691V") %>% dplyr::arrange(date) |> dplyr::mutate(value = slider::slide_mean(.data$value, before = 11L, complete = TRUE), series_id = "smoothed_youth_unemp") %>% dplyr::filter(!is.na(.data$value)) %>% dplyr::bind_rows(df) summ_data <- ts_summarise(df)
# Function to return dot point text for a given series ID summ_dot_point <- function(series_id) { prev <- get_summ(series_id, prev_value, summ_data) %>% round2(1) curr <- get_summ(series_id, latest_value, summ_data) %>% round2(1) curr_date <- get_summ(series_id, latest_date, summ_data) %>% format("%B %Y") unit <- get_summ(series_id, unit, summ_data) if (unit != "Percent") { prev <- pretty_round(prev) curr <- pretty_round(curr) } raw_diff <- get_summ(series_id, d_period_abs, summ_data) diff_sign <- raw_diff %>% round2(1) %>% sign() diff <- dplyr::if_else(unit == "000", pretty_round(abs(raw_diff)), as.character(round2(abs(raw_diff), 1))) perc_diff <- get_summ(series_id, d_period_perc, summ_data) %>% abs() %>% round2(1) out <- dplyr::case_when( diff_sign == 0 ~ paste0(" remained at ", curr), diff_sign == -1 ~ paste0(" fell from ", prev, " to ", curr), diff_sign == 1 ~ paste0(" rose from ", prev, " to ", curr) ) if (unit == "Percent") { out <- paste0(out, " per cent") } out <- dplyr::case_when( diff_sign == 0 ~ out, diff_sign == -1 ~ paste0(out, ", a fall of ", diff), diff_sign == 1 ~ paste0(out, ", a rise of ", diff) ) if (unit == "Percent") { out <- paste0(out, " percentage points") } else { out <- paste0(out, " workers") } out } dot_points <- c( glue::glue("- Victoria's unemployment rate {summ_dot_point(\"A84423354L\")};"), glue::glue("- The number of people employed in Victoria {summ_dot_point(\"A84423349V\")};") )
ftemp_raw_diff <- get_summ("A84423357V", d_period_abs, summ_data) ftemp_perc_diff <- get_summ("A84423357V", d_period_perc, summ_data) %>% round2(1) ftemp_sign <- sign(ftemp_raw_diff) ftemp_pretty_diff <- ftemp_raw_diff %>% abs() %>% pretty_round() ftemp_text <- dplyr::case_when( ftemp_sign == 0 ~ " remained unchanged", ftemp_sign == -1 ~ paste0(" fell by ", ftemp_pretty_diff, " workers (", ftemp_perc_diff, "%)"), ftemp_sign == 1 ~ paste0(" rose by ", ftemp_pretty_diff, " workers (", ftemp_perc_diff, "%)") ) ptemp_raw_diff <- get_summ("pt_emp_vic", d_period_abs, summ_data) ptemp_perc_diff <- get_summ("pt_emp_vic", d_period_perc, summ_data) %>% round2(1) ptemp_sign <- sign(ptemp_raw_diff) ptemp_pretty_diff <- ptemp_raw_diff %>% abs() %>% pretty_round() ptemp_text <- dplyr::case_when( ptemp_sign == 0 ~ " remained unchanged", ptemp_sign == -1 ~ paste0(" fell by ", ptemp_pretty_diff, " workers (", ptemp_perc_diff, "%)"), ptemp_sign == 1 ~ paste0(" rose by ", ptemp_pretty_diff, " workers (", ptemp_perc_diff, "%)") ) dot_points <- c( dot_points, glue::glue(" * Full-time employment {ftemp_text};"), glue::glue(" * Part-time employment {ptemp_text};"), glue::glue("- The number of unemployed people in Victoria {summ_dot_point(\"A84423350C\") %>% gsub(\"workers\", \"people\", .)};"), glue::glue("- Victoria's participation rate {summ_dot_point(\"A84423355R\")};") )
hours_change <- get_summ("A84426256L", d_period_perc, summ_data) %>% round2(1) hours_sign <- sign(hours_change) hours_text <- dplyr::case_when( hours_sign == 0 ~ " didn't change", hours_sign == -1 ~ paste0(" fell by ", abs(hours_change), "%"), hours_sign == 1 ~ paste0(" rose by ", abs(hours_change), "%") ) dot_points <- c( dot_points, glue::glue("- The total number of hours worked in Victoria {hours_text};"), glue::glue("- Victoria's underemployment rate {summ_dot_point(\"A85223450L\")};"), glue::glue("- The youth unemployment rate in Victoria ", summ_dot_point("smoothed_youth_unemp"), " (smoothed using a 12-month rolling average);"), glue::glue("- The unsmoothed, original youth unemployment rate is ", get_summ("A84424691V", latest_value, summ_data) %>% round2(1), " percent, compared to ", get_summ("A84424691V", prev_value, summ_data) %>% round2(1), " percent a month earlier.") )
cat( paste(dot_points, collapse = '\n') ) # save to md for inclusion in email writeLines(dot_points, here::here('inst','dotpoints.md'))
\newpage
abs_labour_force <- get_labourforce_db()
t1 <- table_overview(df = abs_labour_force) |> table_split() t1 <- check_title(t1)
r t1$title
r t1$tbl
\newpage
t2 <- table_gr_sex(df = abs_labour_force) |> table_split() t2 <- check_title(t2)
r t2$title
r t2$tbl
t3 <- table_ind_unemp_state(df = abs_labour_force) |> table_split() t3 <- check_title(t3)
\newpage
r t3$title
r t3$tbl
\newpage
Youth labour market data provides insights into headline figures. Youth labour force data is volatile therefore DJSIR smooths the data by using 12-month averages. While this assists in observing underlying trends, it makes large month-to-month changes in underlying conditions less apparent.
t4 <- table_gr_youth_summary(df = abs_labour_force) |> table_split() t4 <- check_title(t4)
r t4$title
r t4$tbl
\newpage
t5 <- table_gr_youth_unemp_region(df = abs_labour_force) |> table_split() t5 <- check_title(t5)
r t5$title
r t5$tbl
\newpage
t6 <- table_reg_metro_states_unemprate(df = abs_labour_force) |> table_split() t6 <- check_title(t6)
r t6$title
r t6$tbl
\newpage
t7 <- table_reg_metro_emp(df = abs_labour_force) |> table_split() t7 <- check_title(t7)
r t7$title
r t7$tbl
\newpage
t8 <- table_reg_metro_unemp(df = abs_labour_force) |> table_split() t8 <- check_title(t8)
r t8$title
r t8$tbl
\newpage
t9 <- table_reg_metro_unemprate(df = abs_labour_force) |> table_split() t9 <- check_title(t9)
r t9$title
r t9$tbl
\newpage
t10 <- table_reg_metro_partrate(df = abs_labour_force) |> table_split() t10 <- check_title(t10)
r t10$title
r t10$tbl
\newpage
t11 <- table_reg_nonmetro_states_unemprate(df = abs_labour_force) |> table_split() t11 <- check_title(t11)
r t11$title
r t11$tbl
\newpage
t12 <- table_reg_nonmetro_emp(df = abs_labour_force) |> table_split() t12 <- check_title(t12)
r t12$title
r t12$tbl
\newpage
t13 <- table_reg_nonmetro_unemp(df = abs_labour_force) |> table_split() t13 <- check_title(t13)
r t13$title
r t13$tbl
\newpage
t14 <- table_reg_nonmetro_unemprate(df = abs_labour_force) |> table_split() t14 <- check_title(t14)
r t14$title
r t14$tbl
\newpage
t15 <- table_reg_nonmetro_partrate(df = abs_labour_force) |> table_split() t15 <- check_title(t15)
r t15$title
r t15$tbl
\newpage
t16 <- table_industries_summary(df = abs_labour_force) |> table_split() t16 <- check_title(t16)
r t16$title
r t16$tbl
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.