# Set echo=false for all chunks
knitr::opts_chunk$set(echo=FALSE)

Below are links to profession-specific profiles. These contain the outputs present on the summary statistics page, filtered by profession. Only professions with 20 or more respondents are included.

Profession sample sizes

library(magrittr)

if(!exists("data")) stop("Dataframe called data not available. This should be in the function enviroment of render_main_site. Check that this is available in this enviroment.")

profs <- dplyr::select(data, nonCS:non_prof)
prof_freqs <- carsurvey2::calc_multi_col_freqs(profs, c("Yes", "No"))
prof_freqs <- prof_freqs[c(1,2)]

prof_freqs <- prof_freqs[prof_freqs[2] >= 20, ]
prof_freqs[1] <- as.character(prof_freqs[[1]])
colnames(prof_freqs) <- c("Profession", "Sample size")

recode_vals <- c(
  nonCS = "Non Civil Service",
  GSG = "Government Statistician Group",
  GES = "Government Economic Service",
  GSR = "Government Social Research",
  GORS = "Government Operational Research Service",
  sci_eng = "Government Science and Engineering",
  DDAT = "Digital, Data and Technology Profession",
  datasci = "Government Data Scientist",
  non_prof = "Civil Service, no profession membership"
)

prof_freqs$Profession <- dplyr::recode(prof_freqs$Profession, !!!recode_vals)
plot_freqs <- prof_freqs
plot_freqs$Profession <- carsurvey2::break_q_names(prof_freqs$Profession)
plot <- carsurvey2::plot_freqs(plot_freqs, "", "Sample size", n = samples$all, orientation = "h", width = 700, height = 700)

table <- kableExtra::kable_styling(knitr::kable(prof_freqs, row.names = FALSE)) %>% 
  kableExtra::add_footnote(paste0("Sample size = ", samples$all))

carsurvey2::wrap_outputs("prof-freqs", plot, table)
alphabetical <- as.character(prof_freqs$Profession[order(prof_freqs$Profession)])
urls <- format_filter_path(alphabetical)
links <- paste0('<li><a href="', urls, '.html">', alphabetical, "</a></li>")
html <- paste(links, collapse="\n\n")
html <- paste0("<ol>", html, "</ol>")
knitr::raw_html(html)


best-practice-and-impact/CARS2 documentation built on Dec. 19, 2021, 8:47 a.m.