ffverse / ffscrapr

R API Client for Fantasy Football League Platforms
https://ffscrapr.ffverse.com
Other
81 stars 22 forks source link

ff_scoringhistory on Sleeper fails #364

Closed msavoca90 closed 2 years ago

msavoca90 commented 2 years ago

Describe the bug Unable to generate scoring history on Sleeper when attempting to scrape for use with ffsimulator

conn =  sleeper_connect(season = 2022, league_id = 802734610873188352)
scoring_history = ff_scoringhistory(conn)

Error in dplyr::inner_join(): Can't join on x$season x y$season because of incompatible types. x$season is of type character. y$season is of type integer.

tanho63 commented 2 years ago

Hmm. This is because of a new issue related to nflreadr's rosters data - season is being returned as a character instead of an integer like it probably should be. Opening a new issue over there now.

R> nflreadr::load_rosters(TRUE) |> tibble::tibble()
# A tibble: 123,226 × 30
   season team  position depth_chart_position jersey_number status full_name    first_name
   <chr>  <chr> <chr>    <chr>                <chr>         <chr>  <chr>        <chr>     
 1 1920   AKR   DL       E                    0             ACT    Scotty Bier… Bruce     
 2 1920   AKR   DL       E                    0             ACT    Budge Garre… Alfred    
 3 1920   AKR   DL       E                    0             ACT    George John… George    
 4 1920   AKR   DL       DG                   0             ACT    Al Nesser    Alfred    
 5 1920   AKR   DL       DG                   0             ACT    Tommy Tomlin John      
 6 1920   AKR   OL       C                    0             ACT    Russ Bailey  Russell   
 7 1920   AKR   OL       G                    0             ACT    George Brown George    
 8 1920   AKR   OL       G                    0             ACT    Alf Cobb     Alfred    
 9 1920   AKR   OL       OT                   0             ACT    Pike Johnson Karl      
10 1920   AKR   OL       G                    0             ACT    Frank Moran  Frank     
# … with 123,216 more rows, and 22 more variables: last_name <chr>, birth_date <date>,
#   height <chr>, weight <chr>, college <chr>, gsis_id <chr>, espn_id <chr>,
#   sportradar_id <chr>, yahoo_id <chr>, rotowire_id <chr>, pff_id <chr>, pfr_id <chr>,
#   fantasy_data_id <chr>, sleeper_id <chr>, years_exp <int>, headshot_url <chr>,
#   ngs_position <chr>, esb_id <chr>, gsis_it_id <chr>, smart_id <chr>, entry_year <chr>,
#   rookie_year <chr>
tanho63 commented 2 years ago

Resolved with nflverse/nflfastR-roster#47

R> library(ffscrapr)

R> conn =  sleeper_connect(season = 2022, league_id = 802734610873188352)

R> scoring_history = ff_scoringhistory(conn)

R> scoring_history
# A tibble: 115,540 × 35
   season  week gsis_id    sportradar_id sleeper_id player_name   pos   team  points
    <int> <int> <chr>      <chr>         <chr>      <chr>         <chr> <chr>  <dbl>
 1   1999    11 00-0016479 NA            NA         Pat Tillman   DB    ARI     0   
 2   1999     4 00-0001907 NA            NA         Dave Brown    QB    ARI     1.2 
 3   1999     5 00-0001907 NA            NA         Dave Brown    QB    ARI     1.64
 4   1999     6 00-0001907 NA            NA         Dave Brown    QB    ARI     8.28
 5   1999     8 00-0001907 NA            NA         Dave Brown    QB    ARI     2.28
 6   1999     9 00-0001907 NA            NA         Dave Brown    QB    ARI     8.26
 7   1999    10 00-0001907 NA            NA         Dave Brown    QB    ARI    10.3 
 8   1999    11 00-0001907 NA            NA         Dave Brown    QB    ARI     8.3 
 9   1999    12 00-0001907 NA            NA         Dave Brown    QB    ARI     3.44
10   1999     8 00-0006410 NA            NA         Chris Greisen QB    ARI     0.16
# … with 115,530 more rows, and 26 more variables: receiving_fumbles_lost <dbl>,
#   rushing_fumbles_lost <dbl>, sack_fumbles_lost <dbl>, carries <dbl>,
#   interceptions <dbl>, passing_2pt_conversions <dbl>, passing_tds <dbl>,
#   passing_yards <dbl>, receiving_2pt_conversions <dbl>, receiving_first_downs <dbl>,
#   receiving_tds <dbl>, receiving_yards <dbl>, receptions <dbl>,
#   rushing_2pt_conversions <dbl>, rushing_first_downs <dbl>, rushing_tds <dbl>,
#   rushing_yards <dbl>, fg_made_0_19 <dbl>, fg_made_20_29 <dbl>, fg_made_30_39 <dbl>, …