Loading the libraries

library(dplyr)
library(ggplot2)
library(tidyverse)
library(patchwork)
library(ggtext)

Reading the Ultra Rankings CSV

ultra_rankings <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-10-26/ultra_rankings.csv')

Reading the race CSV

race <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-10-26/race.csv')

Data Wrangling for the Analysis of Number of Runners by Years and Gender

# join data sets
rankings <- ultra_rankings %>% left_join(race, by="race_year_id")

rankings$year <- year(rankings$date)

rankings$gender <- as.factor(rankings$gender)
rankings$year <- as.factor(rankings$year)

df <- as.data.frame(table(rankings$year, rankings$gender))

df <- df %>% 
  rename(
    year = Var1,
    gender = Var2,
    number = Freq
  )

df_male <- subset(df, gender == "M")

df_male <- df_male %>% 
  rename(
    number_male = number
  )


df_women <- subset(df, gender == "W")

df_women <- df_women %>% 
  rename(
    number_women = number
  )

df1 <- df_male %>% left_join(df_women, by="year")

visualisation of Number of Participants by Year and Gender

run <- ggplot(df1) +
  geom_segment(aes(x=year, xend=year, y=number_male, yend=number_women), color="grey", size=1.5) +
  geom_point(aes(x=year, y=number_male), color="darkgreen", size=8) +
  geom_point(aes(x=year, y=number_women), color="maroon", size=8) +
  scale_y_continuous(limits=c(0, 22000)) +
  coord_flip() +
  theme_classic()+
  theme(plot.background = element_rect(fill = "white"),
    panel.background = element_rect(fill = "white", colour = "white", size = 0.5, linetype = "solid"),
    axis.text.y = element_text(color="black",size=12),
    axis.text.x = element_text(color="black",size=12),
    axis.title.x = element_text(color = "black",size=12),
    axis.title.y = element_text(color = "black",size=12),
    plot.title = element_text(size = 25,hjust = 0.5,face="bold"),
    plot.subtitle = element_markdown(size=13,hjust = 0.5),
    legend.text = element_text(size = 10),
    legend.title = element_text(size=15))+
  geom_text(aes(x=year, y=number_male, label=number_male),
            hjust=0.4,
            vjust=-1.5,
            color="black",
            size=3.5) +
  geom_text(aes(x=year, y=number_women, label=number_women),
            hjust=0.5,
            vjust=2.2,
            color="black",
            size=3.5) +
  labs(title = "Ultra Trail Runners from 2012 to 2021 by Gender ",
       subtitle = "The number of <span style='color:darkgreen;'>**Men**</span> and 
                  <span style='color:maroon;'>**Women**</span> participating in Ultra Trail have been reduced after the onset of covid-19.",y="Total Number of Runners"
       )

run

Interpretation

The number of participants have highly reduced after the onset of COVID-19 and Further I’ll investigate whether it was because there were no events during the pandemic?

Data Wrangling for the Analysis of Number of events by Year

Events<-race%>%
  mutate(Year=as.Date(date)%>%
           year())%>%
  distinct()%>%
  group_by(Year)%>%
  count(event)%>%
  summarise(Total=sum(n))%>%
  data.frame()

Visualization of Number of Events by Year

p1<-ggplot(Events,aes(x=Year,y=Total, label=Total))+
  geom_segment(aes(x=Year,xend=Year,y=0,yend=Total),colour="saddlebrown",size=1)+
  geom_point(size=15, color="sienna1", fill=alpha("sienna1", 0.8), alpha=1.0, shape=21, stroke=3)+
  geom_text(color = "black", fontface="bold",size = 3)+
  scale_x_continuous(breaks = c(2012,2013,2014,2015,2016,2017,2018,2019,2020,2021))+
  scale_y_continuous(limits=c(0,250),breaks=seq(0, 250, by = 50))+
  theme_classic()+
  theme(plot.background = element_rect(fill="white"),
        panel.background = element_rect(fill="white"),
        panel.grid.major.y  = element_line(colour = "grey"),
        axis.text.y = element_text(color="black",size=12),
        axis.text.x = element_text(color="black",size=12),
        axis.title.x = element_text(color = "black",size=12),
        axis.title.y = element_text(color = "black",size=12),
        plot.title = element_text(colour = "black",face="bold",size=21, hjust=0.5),
        plot.subtitle = element_text(colour = "black",size=12,hjust=0.5),)+
  labs(title="Total Number of Ultra Trail Running Events conducted by Year",
       subtitle = "From the visualization,the number of Ultra Trail Running events conducted after the onset of COVID-19 have been greatly reduced",y="Total number of Events")+
  geom_curve(aes(x = 2019, y = 198, xend = 2020, yend = 100),
             curvature = -0.5, angle = 75,
             color = "black", size = 0.8,
             arrow = arrow(length = unit(0.01, "npc"),
                           type = "closed",
                           ends = "both"))+
  annotate("text", x = 2020, y = 198, label = "Drop in the number events ", color="black",size=4)+
  geom_curve(aes(x = 2019, y = 198, xend = 2020, yend = 100),
             curvature = -0.5, angle = 75,
             color = "black", size = 0.8,
             arrow = arrow(length = unit(0.01, "npc"),
                           type = "closed",
                           ends = "both"))

p1

Patchwork for the dashboard

run/p1