sportsdataverse / hoopR

An R package to quickly obtain clean and tidy men's basketball play by play data.
http://hoopr.sportsdataverse.org/
Other
80 stars 18 forks source link

kp_box 'not found' error #40

Closed andreweatherman closed 2 years ago

andreweatherman commented 2 years ago

Very similar to the scheduling bug that I reported a few days ago:

When running the kp_box function for last season, I run into the following error with numerous games:

Error in kp_box(game_id = game_id, year = 2021) : object 'kenpom' not found

Again, I'm not sure what is causing this error as the url that the function is calling does redirect to a legitimate box score on KenPom. I filtered out games (working with a long list of game IDs for last season) against non-D1 opponents, too, thinking that might solve the issue, but it didn't.

The function calls the following url:

url <- paste0("https://kenpom.com/box.php?", "g=", game_id, "&y=", year)

Running an example game, game_id=6, through the function yields the error mentioned above, kp_box(game_id=6, year=2021), however, the url that the function should be redirecting to does exist: https://kenpom.com/box.php?g=6&y=2021.

The function is working for some games (e.g. kp_box(game_id=1, year=2021)), but I cannot figure out why it is returning an error for others. The missing games do not go into OT, nor are their box scores formatted differently. It's not an issue with specific teams, either. I'm not sure how many box scores this affects, but the issue is certainly not isolated.

saiemgilani commented 2 years ago

Thanks for reporting. I'm working on a bunch of these types of issues. Please keep reporting them in separate issues

saiemgilani commented 2 years ago

This is closed by the most recent release. The referee rankings were causing issues and were not overall necessary, so I removed them altogether

andreweatherman commented 2 years ago

Unfortunate because I was using the function just for referee information but that's okay. Glad you found a fix -- thanks.

saiemgilani commented 2 years ago

Lmao oops. Yeah it felt like a useful thing but apparently not all the refs are ranked and figuring out an NA solve on those takes me like way more lines of code than I care to admit

andreweatherman commented 2 years ago

Okay, so the referee rankings weren't causing all of the issues. I went ahead and removed that call from the function on my end, and it solved some of the errors. The remaining issues lie in the fact that some KenPom box scores simply lack referee information (e.g. https://kenpom.com/box.php?g=1477&y=2021).

Thank you for the quick resolves to all of my bugs, though! I ended up pulling all of the referee information that was available by using purrr::possibly.

saiemgilani commented 2 years ago

you got a solve you want to propose on that section? or should I try to write something

saiemgilani commented 2 years ago

For the record, I was not able to save the referee ranks and solve the zero referee case (I chose to solve the zero case), but I did realize I never implemented a pretty easy function kp_referee() that allows you to pull the ranks should you desire, as well as the gamelog for a referee.