sportsdataverse / hoopR

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

object 'kenpom' not found #94

Closed aqsmith08 closed 2 years ago

aqsmith08 commented 2 years ago

Describe the bug It seems like something is broken with KenPom functions in hoopR (or I'm doing something wrong). I'm also noticing that documentation on the hoopR website is displaying the error too. Screenshot below.

To Reproduce Steps to reproduce the behavior:

> library(hoopR)
> hoopR::kp_hca()
Error in hoopR::kp_hca() : object 'kenpom' not found
> hoopR::kp_conf(2021, conf = "B10")
Error in hoopR::kp_conf(2021, conf = "B10") : object 'kenpom' not found

Expected behavior It does look like values do exist - https://kenpom.com/hca.php - and I would expect that those values would be returned.

Screenshots image

image

aqsmith08 commented 2 years ago

I checked my username & password and that seems to be just fine.

> has_kp_user_and_pw()
[1] TRUE

When I went into the kp_hca function (code) specifically and ran it line by line, I hit an error here:

>       browser <- login()
Error in read_html.response(x$response, ..., base_url = x$url) : 
  Forbidden (HTTP 403).
In addition: Warning message:
In session_set_response(x, resp) : Forbidden (HTTP 403).

Could kenpom.com be blocking the traffic?

aqsmith08 commented 2 years ago

Looks like there was a recent StackOverflow post about the same error. I may try to reset my kenpom.com PW and see if it works.

aqsmith08 commented 2 years ago

Password reset and updating environment via usethis::edit_r_environ() didn't seem to resolve the issue.

> login(user_email = Sys.getenv("KP_USER"), user_pw = Sys.getenv("KP_PW"))
Error in read_html.response(x$response, ..., base_url = x$url) : 
  Forbidden (HTTP 403).
In addition: Warning message:
In session_set_response(x, resp) : Forbidden (HTTP 403).
saiemgilani commented 2 years ago

Yeah, can you confirm you're on v1.8.1+? It's definitely something I'm not really figuring out why it is happening on the docs website still but many seem to resolve the issue locally with the update to 1.8.1. Keep you posted

aqsmith08 commented 2 years ago

It looks like I might not be on the most updated version although I don't see any package updates available via RStudio.

> packageVersion("hoopR")
[1] ‘1.8.0’

Want me to try the package version available via Github from the instructions on the README?

# You can install using the pacman package using the following code:
if (!requireNamespace('pacman', quietly = TRUE)){
  install.packages('pacman')
}
pacman::p_load_current_gh("sportsdataverse/hoopR", dependencies = TRUE, update = TRUE)

Edit: I'll go ahead and update my hoopR package and see if that resolves it. Stay tuned.

aqsmith08 commented 2 years ago

Updating the package fixed it.

> packageVersion("hoopR")
[1] ‘1.8.1’
> library(hoopR)
> foo <- kp_hca()
> head(foo)
           team conf hca hca_rk   pf pf_rk  pts pts_rk  nst nst_rk blk blk_rk elev elev_rk
1    Texas Tech  B12 4.8      1 -5.5     3 11.2      7 -1.6     40 1.6     66 3200      20
2 West Virginia  B12 4.7      2 -5.2     6 12.0      2 -2.6      2 2.1     20 1000      60
3     Air Force  MWC 4.6      3 -3.8    51 10.6     13 -1.1    119 1.4    102 7000       2
4           TCU  B12 4.4      4 -5.4     4  9.8     26 -1.4     74 2.4      8  600     140
5      Colorado  P12 4.3      5 -3.6    61 10.2     20 -0.8    189 1.4    120 5400       5
6    New Mexico  MWC 4.2      6 -3.1    94 11.2      5 -0.7    199 1.1    195 5100       7

I'm going to close this bug and hopefully this is helpful to other folks who have this issue. No idea what is different between the versions but it's something important. Thanks for getting me heading in the right direction.