jimmyday12 / fitzRoy

A set of functions to easily access AFL data
https://jimmyday12.github.io/fitzRoy
Other
126 stars 27 forks source link

Some Fantasy Scores in Fryzigg seem to be wrong #160

Open liam-crow opened 2 years ago

liam-crow commented 2 years ago

Some Fantasy score provided in the package do not match manual calculations


Around 547 entries don't match up out of 129 thousand players.

Probably an easy fix, I'd bet it's due to updated stats after the game, that are adding/removing stats, thus moving the score a bit. I also like to clean the colnames a bit, matches better with fitzroy::afltables colnames

library(dplyr)
library(lubridate)

fryzigg_data <- as_tibble(fitzRoy::fetch_player_stats(2000:2030, comp = 'AFLM', source = 'fryzigg')) %>% 
    select(-match_id, -match_date) %>% 
    rename_with(~gsub('^match_|^player_','',.x)) %>% 
    rename(
        surname = last_name,
        playing_for = team,
        frees_for = free_kicks_for,
        frees_against = free_kicks_against
    ) %>% 
    mutate(
        season = year(date),
        manual_fantasy_points = kicks*3 + handballs*2 +marks*3 +tackles*4 + frees_for + frees_against*-3 + hitouts + goals*6 +behinds
    )

fryzigg_data %>% 
    select(season, date, round, id, first_name, surname, manual_fantasy_points, afl_fantasy_score) %>% 
    filter(manual_fantasy_points != afl_fantasy_score)
jimmyday12 commented 2 years ago

One for @Fryzigg