Workforce Zones

require(devtools)
Loading required package: devtools
Loading required package: usethis
install_version("knitr", version = "1.42", repos = "http://cran.us.r-project.org")
Downloading package from url: http://cran.us.r-project.org/src/contrib/Archive/knitr/knitr_1.42.tar.gz
library("pacman")

p_load(rio, tidyverse, DT)

dat <- import("tenure_data.xlsx")

Counties and Licensed Psychologists in those counties

dat %>% 
  select(c(county, psychologists)) %>% 
  unique() %>% 
  group_by(county) %>% 
  summarize(psychologists = sum(psychologists)) %>% 
  datatable()

Experienced Psychlogists in Counties

dat %>% 
    mutate(experience_cat = factor(issue_cat, 
                                 levels = c("Less than 5 years", 
                                 "between 5 and 10 years", 
                                 "between 10 and 20 years", 
                                 "between 20 and 30 years",
                                 "between 30 and 40", 
                                 "between 40 and 50", 
                                 "50 or over")
                                 )) %>% 
  select(c(county, issue_cat, n_tenure)) %>% 
pivot_wider(names_from = issue_cat, values_from = n_tenure) %>% 
  select(county, 'Less than 5 years', 'between 5 and 10 years', 'between 10 and 20 years', 'between 20 and 30 years', 'between 30 and 40', 'between 40 and 50', '50 or over') %>% 
  datatable()

Percent of tenure category working in an county

dat1 <- dat %>% 
  select(county, issue_cat, n_tenure) %>% 
pivot_wider(names_from = issue_cat, values_from = n_tenure)

dat1 %>% 
 mutate('Less than 5 years' = round((dat1$`Less than 5 years`/232) *100, 
                                     digits = 2), 
         "between 5 and 10 years" = round((dat1$`between 5 and 10 years`/245)*100, 
                                          digits = 2), 
         "between 10 and 20 years" = round((dat1$`between 10 and 20 years`/356)*100, 
                                            digits = 2), 
         "between 20 and 30 years" = round((dat1$`between 20 and 30 years`/268)*100, 
                                           digits = 2),
         "between 30 and 40" = round((dat1$`between 30 and 40`/199)*100, 
                                     digits = 2),
         "between 40 and 50" = round((dat1$`between 40 and 50`/ 56)*100, 
                                     digits = 2),
         "50 or over" = round((dat1$`50 or over`/3)*100, digits = 2)
 ) %>% 
  select(county, 'Less than 5 years', 'between 5 and 10 years', 'between 10 and 20 years', 'between 20 and 30 years', 'between 30 and 40', 'between 40 and 50', '50 or over') %>% 
  datatable()