Last active
July 19, 2018 13:28
-
-
Save PaulC91/4d5fb65b44ca0fc95a9681ad50fd1c5d to your computer and use it in GitHub Desktop.
network graph of world cup players connected by club and country
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | |
| }) |
Author
PaulC91
commented
Jun 13, 2018

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