DSLabs

Author

Zachary Rodavich

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.2.0     ✔ readr     2.1.6
✔ forcats   1.0.1     ✔ stringr   1.6.0
✔ ggplot2   4.0.2     ✔ tibble    3.3.1
✔ lubridate 1.9.4     ✔ tidyr     1.3.2
✔ purrr     1.2.1     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
#loading tidyverse
library(dslabs)
#adding the dslabs library
library(dplyr)
library(ggrepel)
library(ggthemes)
#loading in dplyr, ggthemes, and ggrepel
data("admissions")
#using the dataset for Berkely Admissions
admissions
   major gender admitted applicants
1      A    men       62        825
2      B    men       63        560
3      C    men       37        325
4      D    men       33        417
5      E    men       28        191
6      F    men        6        373
7      A  women       82        108
8      B  women       68         25
9      C  women       34        593
10     D  women       35        375
11     E  women       24        393
12     F  women        7        341
#Showing the dataset that we are working with
ggplot(admissions, aes(x = major, y = gender, fill = admitted)) +
  geom_tile(color = "white", linewidth = 0.5) +  # Create the tiles
  geom_text(aes(label = paste0(admitted, "%")), color = "white", fontface = "bold") +
  facet_wrap(~gender, ncol = 1, scales = "free_y") + 
  scale_fill_gradient(low = "lightgreen", high = "darkgreen") +
  labs(
    title = "Admission Rates to UC Berkeley by Major and Gender",
    x = "Academic Major",
    y = "Gender",
    fill = "Admission %"
  ) +
  theme_minimal() +
  theme(strip.text = element_text(face = "bold", size = 12))

#Generating a heatmap with "Green" as the default color"

I decided to utilize the “Admissions” dataset, as I am currently transferring colleges, and I wanted to have an insight into if there was any gender inequlality when it comes to college/university admissions. The above heatmap shows the percentage of admitted students to UC Berkely, based on their Gender and by their decided and announced Academic Major. If we take a look at the data, we can see that for most majors declared by admitted students, there were more Women being admitted than Men, apart from Majors C and E, which had more Men being admitted who declared that major than Women. This heatmap does illustrate a clear inequality between Men and Women in college admissions, especially at UC Berkeley.

AI Use Attribution Statement

Field Value
Title DSlabs Assignment
Creator Zachary Rodavich
Context DATA 110
Document Type Student assignment
AI Permission AI-NO
AI Categories Debugging, Editing

AI Tools Used

  • Gemini 3 — 2026-04-03 — Debugging
  • Gemini 3 — 2026-04-05 — Debugging
  • Gemini 3 — 2026-04-05 — Showing me how to rework my ggplot into a heatmap

AI Prompt

Explain to me how to rework the code for my existing plot into a heatmap.

Human Role

I modified my code with suggestions provided by the A.I. Software


Generated with AI Attribution Generator