[OC] Birthplaces of Active NHL Players

    by haydendking

    5 Comments

    1. Source: NHL API accessed in R

      library(httr)
      library(jsonlite)
      library(dplyr)

      url <- “https://search.d3.nhle.com/api/v1/search/player?culture=en-us&limit=50000&q=*&active=true”

      players <- GET(url) |>
      content(“text”, encoding = “UTF-8”) |>
      fromJSON(flatten = TRUE) |>
      as_tibble()

      players <- players |>
      transmute(
      player_id = playerId,
      name = name,
      birth_city = birthCity,
      birth_state = birthStateProvince,
      birth_country = birthCountry
      )

      Tools: R (packages: dplyr, ggplot2, sf, usmap, tools, ggfx, grid, cowplot, scales, cowplot, showtext, sysfonts, colorspace)

    2. North American players, I guess. There’s a lot of Europeans in the league that aren’t represented here.

    3. Looks like a lot of the American metro areas are being undercounted because suburbs are treated as individual cities. The Twin Cities, for instance, has a large group of overlapping counts whereas it looks like Toronto’s metro is considered as a unit. Any clarity you can provide?

    4. Wow, that bump over St. Louis is an outlier. I assumed part of it was the Tkachuks, but they were born in Scottsdale and raised in StL.

    Leave A Reply