Chapter 8 Countries and Players

The plot shows the countries and the number of players who have represented their country from year 2000 to 2017. We observe USA is the outright winner with Australia, Russia, France , Germany , Japan and China with representations more than Fifty players

matches_country_winner = 
  matches %>% 
  select(winner_name,winner_ioc)  %>%
  rename ( name = winner_name,ioc = winner_ioc)

matches_country_loser = 
  matches %>% 
  select(loser_name,loser_ioc) %>%
  rename ( name = loser_name,ioc = loser_ioc)

matches_country = unique(rbind(matches_country_winner,matches_country_loser))

matches_country %>%
  group_by(ioc) %>%
  summarise(Count = n()) %>%
  arrange(desc(Count)) %>%
  ungroup() %>%
  mutate(ioc = reorder(ioc,Count)) %>%
  head(20) %>%
  
  ggplot(aes(x = ioc,y = Count)) +
  geom_bar(stat='identity',colour="white", fill = fillColor) +
  geom_text(aes(x = ioc, y = 1, label = paste0("(",Count,")",sep="")),
            hjust=0, vjust=.5, size = 4, colour = 'black',
            fontface = 'bold') +
  labs(x = 'Country', 
       y = 'Count', 
       title = 'Country and Count') +
  coord_flip() +
   theme_bw()