jimmyday12 / fitzRoy

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

Jumper Numbers appearing as NA in fetch_player_stats_afltables() #231

Open liam-crow opened 2 months ago

liam-crow commented 2 months ago

Loading in afltables results in Jumper Numbers not appearing correctly.

# fitzRoy_1.4.0.9000

afltables <- fitzRoy::fetch_player_stats_afltables(2021)

afltables %>% 
    dplyr::select(Date, Season, Round, Playing.for, ID, First.name, Surname, Jumper.No.) %>% 
    dplyr::filter(Season == 2021, Round == 1, is.na(Jumper.No.))

The players that have an "NA" jumper no. are subs, either subbed on or off during the course of the game. image

This can seen by the use of the "up" and "down" arrow used by afltables to denote this status change, example here: https://afltables.com/afl/stats/games/2021/031420210318.html

I believe this wasn't an issue in previous versions of Fitzroy due to it being passed through as a "character", rather than what now is a coerced "numeric" vector.

I would recommend using the following code to remove the non-numeric characters and preserve the raw jumper number, or not coerce the jumper numbers to numeric class.

afltables %>% 
    mutate(
        Jumper.No.Clean= as.numeric(gsub('[^0-9]','', Jumper.No.))
    )
peteowen1 commented 1 month ago

Would be fixed by

https://github.com/jimmyday12/fitzroy_data/pull/6

peteowen1 commented 1 month ago

fixed by https://github.com/jimmyday12/fitzRoy/pull/232