Code
library(tidyverse)
library(gt)
library(gtExtras)
<- read_csv("https://jsuleiman.com/datasets/me_grad_employment.csv") jobs
Data Loading Code
library(tidyverse)
library(gt)
library(gtExtras)
<- read_csv("https://jsuleiman.com/datasets/me_grad_employment.csv") jobs
Adjusted text to remove “%”, fix decimals, and turn - into ()
<- jobs |>
jobs_table mutate(
growth_rate = as.numeric(str_replace(growth_rate, "%", ""))) |>
select(-wage_year) |>
gt() |>
fmt_number(
columns = c(base_employment, projected_employment, annual_openings, median_wage, entry_wage),
decimals = 0,
use_seps = TRUE
|>
) fmt_number(
columns = growth_rate,
accounting = TRUE,
decimals = 1
)
Added a title, adjusted heading, and added sources at the bottom
<- jobs_table |>
jobs_table tab_header(
title = "Maine Occupations 2023"
|>
) tab_options(
heading.align = "left"
|>
) cols_align(
align = "right"
|>
) tab_source_note(
source_note = md("**Source:** https://jsuleiman.com/datasets/me_grad_employment.csv"))
Adjusted label titles
<- jobs_table |>
jobs_table tab_spanner(label = "US $", columns = c(median_wage, entry_wage)) |>
cols_label(
occupation = md("**Occupation**"),
base_employment = md("**Base Employment**"),
projected_employment = md("**Projected Employment**"),
growth_rate = md("**Growth Rate %**"),
annual_openings = md("**Annual Openings**"),
median_wage = md("**Median Wage**"),
entry_wage = md("**Entry Wage**")
)
Added a sum at the bottom of the table
<- suppressWarnings(
jobs_table
|>
jobs_table grand_summary_rows(
columns = c(base_employment, projected_employment, annual_openings),
fns = list(Total = ~sum(.)),
formatter = fmt_number,
decimals = 0,
use_seps = TRUE
) )
Added color to the negative numbers under the growth rate
|>
jobs_table tab_style(
style = cell_text(color = "red", weight = "bold"),
locations = cells_body(
columns = growth_rate,
rows = growth_rate < 0
) )
Maine Occupations 2023 | |||||||
---|---|---|---|---|---|---|---|
Occupation | Base Employment | Projected Employment | Growth Rate % | Annual Openings |
US $
|
||
Median Wage | Entry Wage | ||||||
Lawyers | 2,725 | 2,862 | 5.0 | 121 | $98760 | $66090 | |
Educational, Guidance, and Career Counselors and Advisors | 1,679 | 1,712 | 2.0 | 122 | $56780 | $42910 | |
Education Administrators, Kindergarten through Secondary | 1,673 | 1,683 | 1.0 | 111 | $98800 | $74900 | |
Physical Therapists | 1,580 | 1,667 | 6.0 | 71 | $90590 | $75330 | |
Mental Health and Substance Abuse Social Workers | 1,459 | 1,460 | 0.0 | 100 | $66380 | $49370 | |
Pharmacists | 1,366 | 1,388 | 2.0 | 53 | $135430 | $102210 | |
Nurse Practitioners | 1,332 | 1,804 | 35.0 | 117 | $123140 | $99830 | |
Occupational Therapists | 1,161 | 1,200 | 3.0 | 68 | $79700 | $63760 | |
Librarians and Media Collections Specialists | 914 | 904 | (1.0) | 83 | $59010 | $41020 | |
Instructional Coordinators | 895 | 895 | 0.0 | 76 | $73760 | $53990 | |
Psychologists, All Other | 893 | 920 | 3.0 | 60 | $85520 | $62970 | |
Physician Assistants | 795 | 971 | 22.0 | 61 | $131540 | $109100 | |
Speech-Language Pathologists | 764 | 852 | 12.0 | 52 | $80210 | $60110 | |
Education Administrators, Postsecondary | 752 | 738 | (2.0) | 48 | $82460 | $60440 | |
Health Specialties Teachers, Postsecondary | 706 | 797 | 13.0 | 67 | $84500 | $59510 | |
Art, Drama, and Music Teachers, Postsecondary | 587 | 575 | (2.0) | 45 | $78380 | $51380 | |
Veterinarians | 536 | 571 | 7.0 | 22 | $128240 | $90250 | |
Healthcare Social Workers | 484 | 495 | 2.0 | 42 | $64040 | $54770 | |
Acupuncturists | 432 | 432 | 0.0 | 26 | $65040 | $44520 | |
English Language and Literature Teachers, Postsecondary | 428 | 411 | (4.0) | 30 | $81960 | $61310 | |
Biochemists and Biophysicists | 414 | 388 | (6.0) | 25 | $84440 | $67990 | |
Education Teachers, Postsecondary | 410 | 404 | (1.0) | 31 | $76480 | $51410 | |
Nursing Instructors and Teachers, Postsecondary | 404 | 452 | 12.0 | 38 | $77370 | $55710 | |
Postsecondary Teachers, All Other | 378 | 371 | (2.0) | 28 | $72170 | $43980 | |
Business Teachers, Postsecondary | 309 | 313 | 1.0 | 24 | $81340 | $56730 | |
Biological Science Teachers, Postsecondary | 303 | 311 | 3.0 | 25 | $79220 | $59190 | |
Total | — | 23,379 | 24,576 | — | 1,546 | — | — |
Source: https://jsuleiman.com/datasets/me_grad_employment.csv |