Code
library(tidyverse)
library(gt)
library(gtExtras)
jobs <- read_csv("https://jsuleiman.com/datasets/me_grad_employment.csv")library(tidyverse)
library(gt)
library(gtExtras)
jobs <- read_csv("https://jsuleiman.com/datasets/me_grad_employment.csv")jobs <- read_csv("https://jsuleiman.com/datasets/me_grad_employment.csv")Rows: 26 Columns: 8
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (4): occupation, growth_rate, median_wage, entry_wage
dbl (4): base_employment, projected_employment, annual_openings, wage_year
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
jobs <- jobs |>
mutate(
growth_rate = round((projected_employment - base_employment) / base_employment * 100, 1)
) |>
select(
occupation,
base_employment,
projected_employment,
growth_rate,
annual_openings,
median_wage,
entry_wage
) jobs |>
gt() |>
tab_header(
title = md("**Maine Job Outlook by Occupation (2020–2030)**"),
subtitle = "Base vs. Projected Jobs, Growth, Openings, and Wages"
) |>
tab_style(
style = cell_text(weight = "bold"),
locations = cells_column_labels(everything())
) |>
opt_table_lines(extent = "none") |>
opt_row_striping() |>
cols_align(align = "right", columns = where(is.numeric)) |>
cols_align(align = "left", columns = c(occupation)) |>
fmt_number(columns = c(base_employment, projected_employment, annual_openings),
decimals = 0, sep_mark = ",") |>
fmt_percent(columns = growth_rate, scale_values = FALSE, decimals = 1) |>
fmt_currency(columns = c(median_wage, entry_wage), currency = "USD", decimals = 0) |>
data_color(
columns = growth_rate,
fn = scales::col_numeric(
palette = c("white", "lightblue", "blue"),
domain = NULL
)
)|>
cols_label(
occupation = "Occupation",
base_employment = "Base Employment (2020)",
projected_employment = "Projected Employment (2030)",
growth_rate = "Growth Rate",
annual_openings = "Annual Openings",
median_wage = "Median Wage",
entry_wage = "Entry Wage"
) |>
opt_table_font(font = google_font("Lato")) |>
tab_options(
table.width = pct(100),
data_row.padding = px(4),
heading.title.font.size = 16,
heading.subtitle.font.size = 12
)| Maine Job Outlook by Occupation (2020–2030) | ||||||
|---|---|---|---|---|---|---|
| Base vs. Projected Jobs, Growth, Openings, and Wages | ||||||
| Occupation | Base Employment (2020) | Projected Employment (2030) | Growth Rate | Annual Openings | 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 | 0.6% | 111 | $98800 | $74900 |
| Physical Therapists | 1,580 | 1,667 | 5.5% | 71 | $90590 | $75330 |
| Mental Health and Substance Abuse Social Workers | 1,459 | 1,460 | 0.1% | 100 | $66380 | $49370 |
| Pharmacists | 1,366 | 1,388 | 1.6% | 53 | $135430 | $102210 |
| Nurse Practitioners | 1,332 | 1,804 | 35.4% | 117 | $123140 | $99830 |
| Occupational Therapists | 1,161 | 1,200 | 3.4% | 68 | $79700 | $63760 |
| Librarians and Media Collections Specialists | 914 | 904 | −1.1% | 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.1% | 61 | $131540 | $109100 |
| Speech-Language Pathologists | 764 | 852 | 11.5% | 52 | $80210 | $60110 |
| Education Administrators, Postsecondary | 752 | 738 | −1.9% | 48 | $82460 | $60440 |
| Health Specialties Teachers, Postsecondary | 706 | 797 | 12.9% | 67 | $84500 | $59510 |
| Art, Drama, and Music Teachers, Postsecondary | 587 | 575 | −2.0% | 45 | $78380 | $51380 |
| Veterinarians | 536 | 571 | 6.5% | 22 | $128240 | $90250 |
| Healthcare Social Workers | 484 | 495 | 2.3% | 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.3% | 25 | $84440 | $67990 |
| Education Teachers, Postsecondary | 410 | 404 | −1.5% | 31 | $76480 | $51410 |
| Nursing Instructors and Teachers, Postsecondary | 404 | 452 | 11.9% | 38 | $77370 | $55710 |
| Postsecondary Teachers, All Other | 378 | 371 | −1.9% | 28 | $72170 | $43980 |
| Business Teachers, Postsecondary | 309 | 313 | 1.3% | 24 | $81340 | $56730 |
| Biological Science Teachers, Postsecondary | 303 | 311 | 2.6% | 25 | $79220 | $59190 |
To make the column headings bold, I used tab_style() with cell_text(weight = “bold”). This makes the headers more noticeable and makes it simpler to distinguish them from the numbers below. It improves the table’s organization and makes it easier for readers to understand where the data starts and the labels finish.
I used opt_table_lines(extent = “none”) to eliminate the thick lines that separated the cells in order to maintain the table’s cleanliness. I used opt_row_striping() to add striped rows in instead of borders. This keeps the table from appearing overly crowded while making it simpler to follow each row across it.
All of the numerical columns (like jobs, earnings, and growth rates) were aligned to the right using cols_align(). Because of matching the numbers in each column became easier. I aligned the text for the job titles to the left, which is how English words are typically read. The table appears more balanced and readable when the numbers are on the right and the sentences are on the left.
I rounded big numbers and added commas to make them easier to read using fmt_number() to improve the numbers’ appearance. Additionally, I displayed wages in full dollars using fmt_currency() and growth rates with one decimal place using fmt_percent(). This keeps the table tidy and keeps uneeded features from being displayed.
I used data_color() to add color to the growth_rate column even though it wasn’t necessary. This meets with Chapter 11 Rule 5, which says that important information should be highlighted. To make them less noticeable, I picked colors that range from grey to green. This keeps the table from seeming too vibrant or distracting while letting users easily determine which jobs are expanding the fastest.
https://chatgpt.com/share/67eef4af-797c-800f-8794-da7a37a17370