data <- read_excel("../00_data/myData.xlsx")
data
## # A tibble: 236 × 20
## TEAMID TEAM PAKE PAKERANK PASE PASERANK GAMES W L WINPERCENT R64
## <dbl> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1 Abil… 0.7 45 0.7 52 3 1 2 0.333 2
## 2 2 Akron -0.9 179 -1.1 187 4 0 4 0 4
## 3 3 Alab… -2.1 211 -2.9 220 10 5 5 0.5 5
## 4 4 Alba… -0.4 147 -0.3 138 3 0 3 0 3
## 5 6 Amer… -0.5 160 -0.4 150 3 0 3 0 3
## 6 8 Ariz… -1.7 206 -2.5 216 28 17 11 0.607 11
## 7 9 Ariz… -2 209 -1.9 206 5 1 4 0.2 4
## 8 10 Arka… 4.3 11 3.5 16 18 11 7 0.611 7
## 9 11 Arka… 0 76 0 78 1 0 1 0 1
## 10 12 Aubu… 0.6 53 1.4 30 11 7 4 0.636 4
## # ℹ 226 more rows
## # ℹ 9 more variables: R32 <dbl>, S16 <dbl>, E8 <dbl>, F4 <dbl>, F2 <dbl>,
## # CHAMP <dbl>, TOP2 <dbl>, F4PERCENT <dbl>, CHAMPPERCENT <dbl>
data %>% count(TEAM)
## # A tibble: 236 × 2
## TEAM n
## <chr> <int>
## 1 Abilene Christian 1
## 2 Akron 1
## 3 Alabama 1
## 4 Albany 1
## 5 American 1
## 6 Arizona 1
## 7 Arizona St. 1
## 8 Arkansas 1
## 9 Arkansas Pine Bluff 1
## 10 Auburn 1
## # ℹ 226 more rows
TEAM_levels <- c("Alabama", "Arkansas", "Auburn")
data_rev <- data %>%
mutate(TEAM = TEAM %>% factor(levels = TEAM_levels))
Make two bar charts here - one before ordering another after
data %>%
mutate(TEAM = fct_recode(TEAM,
"Alabama" = "Albany",
"American" = "Arizona",
"Auburn" = "Arkansas")) %>%
count(TEAM)
## # A tibble: 233 × 2
## TEAM n
## <fct> <int>
## 1 Abilene Christian 1
## 2 Akron 1
## 3 Alabama 2
## 4 American 2
## 5 Arizona St. 1
## 6 Auburn 2
## 7 Arkansas Pine Bluff 1
## 8 Austin Peay 1
## 9 Baylor 1
## 10 Belmont 1
## # ℹ 223 more rows
data %>%
mutate(TEAM = fct_collapse(TEAM,
Alabama = "Albany",
Other = "American", "Arizona")) %>%
count(TEAM)
## # A tibble: 235 × 2
## TEAM n
## <fct> <int>
## 1 "Abilene Christian" 1
## 2 "Akron" 1
## 3 "Alabama" 2
## 4 "Other" 1
## 5 "" 1
## 6 "Arizona St." 1
## 7 "Arkansas" 1
## 8 "Arkansas Pine Bluff" 1
## 9 "Auburn" 1
## 10 "Austin Peay" 1
## # ℹ 225 more rows
data %>%
mutate(TEAM = fct_lump(TEAM)) %>%
count(TEAM)
## # A tibble: 236 × 2
## TEAM n
## <fct> <int>
## 1 Abilene Christian 1
## 2 Akron 1
## 3 Alabama 1
## 4 Albany 1
## 5 American 1
## 6 Arizona 1
## 7 Arizona St. 1
## 8 Arkansas 1
## 9 Arkansas Pine Bluff 1
## 10 Auburn 1
## # ℹ 226 more rows