meysubb / cfbscrapR-archived

CFB R Package
GNU General Public License v3.0
25 stars 9 forks source link

Error in `[<-.data.frame`(`*tmp*`, kickoff_ind, "ep_before", value = c(0, : replacement has 7 rows, data has 1 #16

Closed benjaminrobinson closed 4 years ago

benjaminrobinson commented 4 years ago
## devtools::install_github("meysubb/cfbscrapR")
library(cfbscrapR)
#> Warning: replacing previous import 'mgcv::multinom' by 'nnet::multinom' when
#> loading 'cfbscrapR'
library(tidyverse)

year = 2001:2019
week = 1:14
df = expand.grid(year, week) %>% setNames(c('year', 'week'))

df %>%
  mutate(pbp = purrr::pmap(
    list(x = year,
         y = week),
    .f = function(x, y) {
      cfb_pbp_data(
        year = x,
        week = y,
        team = "Pittsburgh",
        epa_wpa = TRUE
      )
    }
  )) -> pitt
#> Warning in cfb_pbp_data(year = x, week = y, team = "Pittsburgh", epa_wpa = TRUE): Most likely a bye week, the data pulled from the API was empty. Returning nothing
#>             for this one week or team.
#> Warning in cfb_pbp_data(year = x, week = y, team = "Pittsburgh", epa_wpa = TRUE): Most likely a bye week, the data pulled from the API was empty. Returning nothing
#>             for this one week or team.

#> Warning in cfb_pbp_data(year = x, week = y, team = "Pittsburgh", epa_wpa = TRUE): Most likely a bye week, the data pulled from the API was empty. Returning nothing
#>             for this one week or team.

#> Warning in cfb_pbp_data(year = x, week = y, team = "Pittsburgh", epa_wpa = TRUE): Most likely a bye week, the data pulled from the API was empty. Returning nothing
#>             for this one week or team.

#> Warning in cfb_pbp_data(year = x, week = y, team = "Pittsburgh", epa_wpa = TRUE): Most likely a bye week, the data pulled from the API was empty. Returning nothing
#>             for this one week or team.

#> Warning in cfb_pbp_data(year = x, week = y, team = "Pittsburgh", epa_wpa = TRUE): Most likely a bye week, the data pulled from the API was empty. Returning nothing
#>             for this one week or team.

#> Warning in cfb_pbp_data(year = x, week = y, team = "Pittsburgh", epa_wpa = TRUE): Most likely a bye week, the data pulled from the API was empty. Returning nothing
#>             for this one week or team.

#> Warning in cfb_pbp_data(year = x, week = y, team = "Pittsburgh", epa_wpa = TRUE): Most likely a bye week, the data pulled from the API was empty. Returning nothing
#>             for this one week or team.

#> Warning in cfb_pbp_data(year = x, week = y, team = "Pittsburgh", epa_wpa = TRUE): Most likely a bye week, the data pulled from the API was empty. Returning nothing
#>             for this one week or team.
#> Warning in log(adj_yd_line): NaNs produced
#> Warning in cfb_pbp_data(year = x, week = y, team = "Pittsburgh", epa_wpa = TRUE): Most likely a bye week, the data pulled from the API was empty. Returning nothing
#>             for this one week or team.
#> Warning in log(adj_yd_line): NaNs produced
#> Warning in cfb_pbp_data(year = x, week = y, team = "Pittsburgh", epa_wpa = TRUE): Most likely a bye week, the data pulled from the API was empty. Returning nothing
#>             for this one week or team.

#> Warning in cfb_pbp_data(year = x, week = y, team = "Pittsburgh", epa_wpa = TRUE): Most likely a bye week, the data pulled from the API was empty. Returning nothing
#>             for this one week or team.
#> Error in `[<-.data.frame`(`*tmp*`, kickoff_ind, "ep_before", value = c(0, : replacement has 7 rows, data has 1

Created on 2019-12-29 by the reprex package (v0.3.0)

R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] forcats_0.4.0   stringr_1.4.0   dplyr_0.8.3     purrr_0.3.3    
 [5] readr_1.3.1     tidyr_1.0.0     tibble_2.1.3    ggplot2_3.2.1  
 [9] tidyverse_1.3.0 cfbscrapR_0.0.1

loaded via a namespace (and not attached):
 [1] ggrepel_0.8.1     Rcpp_1.0.3        lubridate_1.7.4   lattice_0.20-38  
 [5] ps_1.3.0          assertthat_0.2.1  zeallot_0.1.0     digest_0.6.23    
 [9] R6_2.4.1          cellranger_1.1.0  backports_1.1.5   reprex_0.3.0     
[13] evaluate_0.14     httr_1.4.1        pillar_1.4.2      rlang_0.4.2      
[17] lazyeval_0.2.2    curl_4.3          readxl_1.3.1      rstudioapi_0.10  
[21] whisker_0.4       callr_3.3.2       Matrix_1.2-17     rmarkdown_1.18   
[25] splines_3.6.1     munsell_0.5.0     broom_0.5.2       compiler_3.6.1   
[29] modelr_0.1.5      xfun_0.11         pkgconfig_2.0.3   clipr_0.7.0      
[33] mgcv_1.8-28       htmltools_0.4.0   nnet_7.3-12       tidyselect_0.2.5 
[37] crayon_1.3.4      dbplyr_1.4.2      withr_2.1.2       grid_3.6.1       
[41] nlme_3.1-140      jsonlite_1.6      gtable_0.3.0      lifecycle_0.1.0  
[45] DBI_1.0.0         magrittr_1.5      scales_1.1.0      cli_1.1.0        
[49] stringi_1.4.3     fs_1.3.1          xml2_1.2.2        ellipsis_0.3.0   
[53] generics_0.0.2    vctrs_0.2.0       tools_3.6.1       glue_1.3.1       
[57] hms_0.5.2         processx_3.4.1    yaml_2.2.0        colorspace_1.4-1 
[61] sessioninfo_1.1.1 rvest_0.3.5       knitr_1.26        haven_2.2.0
meysubb commented 4 years ago

I'll take a look at this thanks.

meysubb commented 4 years ago

Note to self: specifically test year = 2012, week=1.

meysubb commented 4 years ago

This should be fixed, give it a go please.

benjaminrobinson commented 4 years ago

Got it to work! Thanks, Meyappan!