R Markdown

player_region <- read_csv("players region - Sheet1.csv", show_col_types = FALSE) %>%
  count(Region) %>%
  filter(Region == c("East Midlands", "East of England", "London", "North East", "North West", "South East", "South West", "West Midlands", "Yorkshire and The Humber"))
## Warning: There was 1 warning in `filter()`.
## ℹ In argument: `==...`.
## Caused by warning in `Region == c("East Midlands", "East of England", "London", "North East",
##     "North West", "South East", "South West", "West Midlands",
##     "Yorkshire and The Humber")`:
## ! longer object length is not a multiple of shorter object length
player_region
## # A tibble: 9 × 2
##   Region                       n
##   <chr>                    <int>
## 1 East Midlands                3
## 2 East of England              9
## 3 London                      20
## 4 North East                   6
## 5 North West                  24
## 6 South East                   8
## 7 South West                   4
## 8 West Midlands                9
## 9 Yorkshire and The Humber    11
england <- read_sf("England_rgn_2022_bfc", "england_rgn_2022_bfc") %>%
  select(name) %>%
  mutate(players_per_region = c(24, 20, 3, 11, 9, 6, 8, 4, 9))
england
## Simple feature collection with 9 features and 2 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: 82668.52 ymin: 5336.966 xmax: 655653.8 ymax: 657536.3
## Projected CRS: OSGB36 / British National Grid
## # A tibble: 9 × 3
##   name                                               geometry players_per_region
## * <chr>                                    <MULTIPOLYGON [m]>              <dbl>
## 1 North West               (((316153.5 478554.9, 316162.4 47…                 24
## 2 London                   (((509398.9 171286.5, 509394 1712…                 20
## 3 East Midlands            (((420929.8 329708.9, 420926 3297…                  3
## 4 Yorkshire and The Humber (((404820.7 406551.6, 404771.9 40…                 11
## 5 West Midlands            (((346944.6 220143.1, 346976.4 22…                  9
## 6 North East               (((409301.3 511860.5, 409300.6 51…                  6
## 7 South East               (((428953.2 84807.5, 428952.6 848…                  8
## 8 South West               (((83983.76 5366.8, 83979.29 5373…                  4
## 9 East of England          (((499139.4 205434.5, 499116.5 20…                  9
gg <- ggplot(england) +
  geom_sf_interactive(color = "white", aes(tooltip = paste("<strong>", england$name, "<strong>", "<br>", "Number of players:",
                                                           england$players_per_region),
                          data_id = england$name, fill = players_per_region)) +
  scale_fill_gradient(name = "Number of Players per\nRegion in England", low = "dodgerblue", high = "dodgerblue4") +
  labs(title = "English World Cup Players per Region", subtitle = "The Number of Players on the 2002 to 2022 World Cup Rosters Born in Each
       Region in England", caption = "Plot Made By Karyna Steele\nMap shapefile from European Environment Agency\nData Collected from Wikepedia") +
  theme_void()

girafe(ggobj = gg)
## Warning: Use of `england$name` is discouraged.
## ℹ Use `name` instead.
## Warning: Use of `england$players_per_region` is discouraged.
## ℹ Use `players_per_region` instead.
## Warning: Use of `england$name` is discouraged.
## ℹ Use `name` instead.