mitchell_region_einstein_rep

blair_red <- "#a7000a"
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.5.1     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.1
✔ purrr     1.0.2     
── 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
raw <- read_csv("einstein_representation.csv")
Rows: 108 Columns: 14
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr  (1): region
dbl (13): actual, actual01, actual23, expected, expected01, expected23, diff...

ℹ 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.
data <- raw %>%
    filter(
        size > 25,
        ratio01 != 0
    ) %>%
    arrange(desc(ratio01))


ggplot(data, aes(x = reorder(region, ratio01), y = ratio01))+
        geom_bar(position = "stack", stat = "identity", fill = "coral", color = "black") + 
            labs(title = "Captain and First Pick", 
                 x = "Region", y = "Ratio for Captain and First Pick Einsteins", fill = "Level") +coord_flip() + theme_bw()

data2 <- raw %>%
    filter(
        size > 25,
        ratio23 != 0
    ) %>%
    arrange(desc(ratio23))

ggplot(data2, aes(x = reorder(region, ratio23), y = ratio23))+
        geom_bar(position = "stack", stat = "identity", fill = "steelblue", color = "black") + 
            labs(title = "Second and Third Pick", 
                 x = "Region", y = "Ratio for Second and Third Pick Einsteins", fill = "Level") +coord_flip() + theme_bw()

data3 <- raw %>%
    filter(
        size > 25,
        ratio != 0
    ) %>%
    arrange(desc(ratio))

ggplot(data3, aes(x = reorder(region, ratio), y = ratio))+
        geom_bar(position = "stack", stat = "identity", fill = blair_red, color = "black") + 
            labs(title = "Einsteins", x = "Region", y = "Ratio for Einsteins", fill = "Level") +coord_flip() + theme_bw()