Skip to content

Instantly share code, notes, and snippets.

@PaulC91
Last active July 19, 2018 13:28
Show Gist options
  • Select an option

  • Save PaulC91/4d5fb65b44ca0fc95a9681ad50fd1c5d to your computer and use it in GitHub Desktop.

Select an option

Save PaulC91/4d5fb65b44ca0fc95a9681ad50fd1c5d to your computer and use it in GitHub Desktop.
network graph of world cup players connected by club and country
library(rvest)
library(tidyverse)
library(tidygraph)
library(ggraph)
wc_squads <- html("https://en.wikipedia.org/wiki/2018_FIFA_World_Cup_squads")
tables <- wc_squads %>%
html_table()
teams <- c("Egypt", "Russia", "Saudi Arabia", "Uruguay",
"Iran", "Morocco", "Portugal", "Spain",
"Australia", "Denmark", "France", "Peru",
"Argentina", "Croatia", "Iceland", "Nigeria",
"Brazil", "Costa Rica", "Serbia", "Switzerland",
"Germany", "Mexico", "South Korea", "Sweden",
"Belgium", "England", "Panama", "Tunisia",
"Colombia", "Japan", "Poland", "Senegal")
df <- map_df(1:32, ~ {
tables[[.x]] %>%
mutate(Country = teams[.x]) %>%
select(Player, Country, Club)
})
@PaulC91
Copy link
Author

PaulC91 commented Jun 13, 2018

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment