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

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

Grade 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.")

order <- c(
  "Executive Officer (or equivalent)",
  "Higher Executive Officer (or equivalent)",
  "Senior Executive Officer (or equivalent)",
  "Grade 7 (or equivalent)",
  "Grade 6 (or equivalent)",
  "Fast Stream",
  "Other - NHS",
  "Other"
)
grade_freqs <- factor(data$grade, levels = order)
grade_freqs <- data.frame(table(grade_freqs))
grade_freqs <- grade_freqs[grade_freqs[2] >= 20, ]
grade_freqs[1] <- as.character(grade_freqs[[1]])
colnames(grade_freqs) <- c("Department", "Sample size")
freqs_plot <- grade_freqs
freqs_plot[1] <- stringr::str_wrap(freqs_plot[[1]], width = 40)
freqs_plot[1] <- gsub("\\n", "<br>", freqs_plot[[1]])
freqs_plot[1] <- factor(freqs_plot[[1]], levels = freqs_plot[[1]])
plot <- carsurvey2::plot_freqs(freqs_plot, "", "Sample size", n = samples$all, font_size = 14, orientation = "h", width = 700, height = 400)

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

carsurvey2::wrap_outputs("dep-freqs", plot, table)
grades <- data.frame(table(data$grade))
grades_list <- grades[grades[2] >= 20, ]
grades_list$Var1 <- factor(grades_list$Var1, levels = order)
grades_list <- grades_list[order(grades_list$Var1), ]

urls <- format_filter_path(grades_list$Var1)
links <- paste0('<li><a href="', urls, '.html">', grades_list$Var1, "</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.