Assignment 4

Author

Emma Whipkey

BAN 350 Assignment 4

Occupational Employment for Jobs in Maine Requiring a Master's, Doctoral, or Professional Degree

The jobs dataset used in this assignment contains employment statistics and projections for occupations in Maine that require a master’s, doctoral, or professional degree. Using the gt package in R, I created a table that follows six of the guidelines suggested in chapter 11 of Jonathan Schwabish’s Better Data Visualizations.

Code
library(tidyverse)
library(gt)
library(gtExtras)
jobs <- read_csv("https://jsuleiman.com/datasets/me_grad_employment.csv")
Code
jobs$growth_rate = as.numeric(gsub("\\%", "", jobs$growth_rate))
jobs$entry_wage = as.numeric(gsub("\\$", "", jobs$entry_wage))
jobs$median_wage = as.numeric(gsub("\\$", "", jobs$median_wage))
Code
jobs |> 
  select(-wage_year) |>
  rename("Occupation" = occupation, "Base Employment" = base_employment, "Projected Employment" = projected_employment, "Growth Rate (%)" = growth_rate, "Annual Openings" = annual_openings,  "Median Wage (US $)" = median_wage, "Entry Wage (US $)" = entry_wage) |>
  gt() |>
  tab_header(
    title = "Maine Occupational Employment Outlook for Jobs Requiring Master’s, Doctoral, or Professional Degrees",
    subtitle = glue::glue("for Wage Year 2023")
  )  |>
  opt_align_table_header(align = "left") |>
  tab_style(
    style = "align:left; font-weight: bold",
    locations = cells_column_labels()
  ) |>  
  tab_style(
    style = cell_fill(
      color = "lightgreen"),
    locations = cells_body(columns = "Growth Rate (%)", 
      rows = !!sym("Growth Rate (%)") >= 20)
  ) |> 
  tab_source_note(source_note = "Source: https://jsuleiman.com/datasets/me_grad_employment.csv"
  ) |> 
  tab_style(
    style = cell_text(
      color = "grey",
      size = "small"),
    locations = cells_source_notes()
  )
Maine Occupational Employment Outlook for Jobs Requiring Master’s, Doctoral, or Professional Degrees
for Wage Year 2023
Occupation Base Employment Projected Employment Growth Rate (%) Annual Openings Median Wage (US $) Entry Wage (US $)
Lawyers 2725 2862 5 121 98760 66090
Educational, Guidance, and Career Counselors and Advisors 1679 1712 2 122 56780 42910
Education Administrators, Kindergarten through Secondary 1673 1683 1 111 98800 74900
Physical Therapists 1580 1667 6 71 90590 75330
Mental Health and Substance Abuse Social Workers 1459 1460 0 100 66380 49370
Pharmacists 1366 1388 2 53 135430 102210
Nurse Practitioners 1332 1804 35 117 123140 99830
Occupational Therapists 1161 1200 3 68 79700 63760
Librarians and Media Collections Specialists 914 904 -1 83 59010 41020
Instructional Coordinators 895 895 0 76 73760 53990
Psychologists, All Other 893 920 3 60 85520 62970
Physician Assistants 795 971 22 61 131540 109100
Speech-Language Pathologists 764 852 12 52 80210 60110
Education Administrators, Postsecondary 752 738 -2 48 82460 60440
Health Specialties Teachers, Postsecondary 706 797 13 67 84500 59510
Art, Drama, and Music Teachers, Postsecondary 587 575 -2 45 78380 51380
Veterinarians 536 571 7 22 128240 90250
Healthcare Social Workers 484 495 2 42 64040 54770
Acupuncturists 432 432 0 26 65040 44520
English Language and Literature Teachers, Postsecondary 428 411 -4 30 81960 61310
Biochemists and Biophysicists 414 388 -6 25 84440 67990
Education Teachers, Postsecondary 410 404 -1 31 76480 51410
Nursing Instructors and Teachers, Postsecondary 404 452 12 38 77370 55710
Postsecondary Teachers, All Other 378 371 -2 28 72170 43980
Business Teachers, Postsecondary 309 313 1 24 81340 56730
Biological Science Teachers, Postsecondary 303 311 3 25 79220 59190
Source: https://jsuleiman.com/datasets/me_grad_employment.csv

Rule 1: Offset the Headers from the Body

To offset the headers from the body of the table, I used the bold parameter in the font-weight argument in tab_style on the cells_column_labels location to bold the column labels.

Rule 2: Use Subtle Dividers Instead of Heavy Gridlines

gt’s default style separates body rows with light grey lines and headers/footers with thicker grey lines for a subtle dividing effect.

Rule 3: Right-Align Numbers and Headers

gt’s default style right-aligns the numbers in the body of the table.

Rule 4: Left-Align Text and Headers

I used the align=left parameter in opt_align_table_header to left-align the title and subtitle text, and the align:left argument in tab_style on the cells_column_labels location to left-align the column labels. gt’s default style left-aligns the text in the Occupation column.

Rule 5: Select The Appropriate Level of Precision

The jobs dataset contains only integers, so I did not need to adjust decimal places using fmt_number.

Rule 8: Highlight Outliers

I used the lightgreen parameter in the cell_fill argument in tab_style, with conditional formatting using the helper cells_body, to highlight outliers in the Growth Rate (%) column with a light green color fill. Two occupations in Maine had projected employment growth over 20%: nurse practitioners (35%) and physician assistants (22%).