Visualisation of Fantasy Points

May 14, 2018
By

(This article was first published on Analysis of AFL, and kindly contributed to R-bloggers)

Recently I was on twitter and saw this tweet here. Being a Connor Blakely fan I thought to myself I wonder if those are actualy good odds and if I could visualise this.

So what is the theme of the thread, well it seems as though Chris and SgtButane think that Connor is likely to get more than 110 fantasy points and that he has a better fantasy record at home vs away.

library(tidyverse)
## -- Attaching packages -------------------------------- tidyverse 1.2.1 --
## v ggplot2 2.2.1     v purrr   0.2.5
## v tibble  1.4.2     v dplyr   0.7.5
## v tidyr   0.8.1     v stringr 1.3.0
## v readr   1.1.1     v forcats 0.3.0
## -- Conflicts ----------------------------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(fitzRoy)

df<-fitzRoy::get_footywire_stats(9514:9576)
## Getting data from footywire.com
## Finished getting data
df1<-fitzRoy::player_stats
df2<-rbind(df1, df) 
df2%>%
   select(Player, AF, Date, Status)%>%
   filter(Player %in% c("Connor Blakely"))%>%
   ggplot(aes(x=Date, y=AF, colour=Status))+
   geom_point()+
   geom_segment(aes(x=Date, xend=Date,y=0, yend=AF ))+
   geom_hline(yintercept =109) +ggtitle("Conor Blakely AF scores")+
   ylab("AF Score") +ylim(0,150) +geom_text(aes(label=AF),vjust=-1)

Does that look like a good bet? You be the judge!

Update

Received an email asking how would I compare two players?

Let me compare Connor Blakely to Jack Steele

library(tidyverse)
library(fitzRoy)

df<-fitzRoy::get_footywire_stats(9514:9576)
## Getting data from footywire.com
## Finished getting data
df1<-fitzRoy::player_stats
df2<-rbind(df1, df) 
df2%>%
   select(Player, AF, Date, Status)%>%
   filter(Player %in% c("Connor Blakely", "Jack Steele"))%>%
   ggplot(aes(x=Date, y=AF, colour=Status))+
   geom_point()+
   geom_segment(aes(x=Date, xend=Date,y=0, yend=AF ))+
   geom_hline(yintercept =109) +ggtitle("Compare the pair")+
   ylab("AF Score") +ylim(0,150) +geom_text(aes(label=AF),vjust=-1)                       +facet_wrap(~Player)

All you have to do is add the Player to the filter and the facet_wrap(~Player) line and you are good to go.

To leave a comment for the author, please follow the link and comment on their blog: Analysis of AFL.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers

Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)