Chapter 9 Rankings and Year
We display the players and the No 1 rankings that they have held in each year. We plot a bar graph which shows the number of years they have at least got a No. 1 ranking. The players may have slipped to rankings lower than No 1 in the same year. This shows the persistence and longevity of the players.
players_rankings = inner_join(players,rankings)
players_rankings$year = str_sub(players_rankings$ranking_date,1,4)
players_rankings$month = str_sub(players_rankings$ranking_date,5,6)
players_rankings_rank_one = players_rankings %>% filter(ranking == 1)
players_rankings_rank_one_year =
players_rankings_rank_one %>%
group_by(first_name,last_name,year) %>%
tally()
players_rankings_rank_one_year = players_rankings_rank_one_year %>% select(-n)
players_rankings_rank_one_year = unique(players_rankings_rank_one_year)
players_rankings_rank_one_year %>%
mutate(FullName = paste0(first_name," ",last_name,"")) %>%
group_by(FullName) %>%
summarise(Count = n()) %>%
arrange(desc(Count)) %>%
ungroup() %>%
mutate(FullName = reorder(FullName,Count)) %>%
head(10) %>%
ggplot(aes(x = FullName,y = Count)) +
geom_bar(stat='identity',colour="white", fill = fillColor) +
geom_text(aes(x = FullName, y = 1, label = paste0("(",Count,")",sep="")),
hjust=0, vjust=.5, size = 4, colour = 'black',
fontface = 'bold') +
labs(x = 'Name',
y = 'Count',
title = 'Name and Count') +
coord_flip() +
theme_bw()
The usual names such as Steffi Graf , Serena Williams , Lindsay Davenport , Monica Seles and Martina Hingis have dominated womens tennis for the past Two decades.