Skip to content

Commit

Permalink
changed f(x) that expanded to 2001 data as allowing for that year to …
Browse files Browse the repository at this point in the history
…pass through (#114)
  • Loading branch information
andreweatherman committed May 1, 2023
1 parent 8ccc33b commit 8726723
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion R/kp_misc_stats.R
Expand Up @@ -530,7 +530,7 @@ kp_game_attrs <- function(
#' try(kp_fanmatch(date="2022-02-22"))
#' }

kp_fanmatch <- function(date = "2022-02-22"){
kp_fanmatch <- function(date){
tryCatch(
expr = {
if (!has_kp_user_and_pw()) stop("This function requires a KenPom subscription e-mail and password combination, set as the system environment variables KP_USER and KP_PW.", "\n See ?kp_user_pw for details.", call. = FALSE)
Expand Down
20 changes: 10 additions & 10 deletions R/kp_ratings_tables.R
Expand Up @@ -49,9 +49,9 @@ kp_pomeroy_ratings <- function(min_year, max_year = most_recent_mbb_season()){
expr = {
if (!has_kp_user_and_pw()) stop("This function requires a KenPom subscription e-mail and password combination,\n set as the system environment variables KP_USER and KP_PW.", "\n See ?kp_user_pw for details.", call. = FALSE)
browser <- login()
if (!(is.numeric(min_year) && nchar(min_year) == 4 && min_year >= 2002)) {
if (!(is.numeric(min_year) && nchar(min_year) == 4 && min_year >= 2001)) {
# Check if year is numeric, if not NULL
cli::cli_abort("Enter valid min_ as a number (YYYY), data only goes back to 2002")
cli::cli_abort("Enter valid min_ as a number (YYYY), data only goes back to 2001")
}

years <- min_year:max_year
Expand Down Expand Up @@ -166,9 +166,9 @@ kp_efficiency <- function(min_year, max_year = most_recent_mbb_season()){
expr = {
if (!has_kp_user_and_pw()) stop("This function requires a KenPom subscription e-mail and password combination,\n set as the system environment variables KP_USER and KP_PW.", "\n See ?kp_user_pw for details.", call. = FALSE)
browser <- login()
if (!(is.numeric(min_year) && nchar(min_year) == 4 && min_year >= 2002)) {
if (!(is.numeric(min_year) && nchar(min_year) == 4 && min_year >= 2001)) {
# Check if year is numeric, if not NULL
cli::cli_abort("Enter valid min_year as a number (YYYY), data only goes back to 2002")
cli::cli_abort("Enter valid min_ as a number (YYYY), data only goes back to 2001")
}


Expand Down Expand Up @@ -340,9 +340,9 @@ kp_fourfactors <- function(min_year, max_year = most_recent_mbb_season()){
expr = {
if (!has_kp_user_and_pw()) stop("This function requires a KenPom subscription e-mail and password combination,\n set as the system environment variables KP_USER and KP_PW.", "\n See ?kp_user_pw for details.", call. = FALSE)
browser <- login()
if (!(is.numeric(min_year) && nchar(min_year) == 4 && min_year >= 2002)) {
if (!(is.numeric(min_year) && nchar(min_year) == 4 && min_year >= 2001)) {
# Check if year is numeric, if not NULL
cli::cli_abort("Enter valid min_year as a number (YYYY), data only goes back to 2002")
cli::cli_abort("Enter valid min_ as a number (YYYY), data only goes back to 2001")
}


Expand Down Expand Up @@ -458,9 +458,9 @@ kp_pointdist <- function(min_year, max_year = most_recent_mbb_season()){
expr = {
if (!has_kp_user_and_pw()) stop("This function requires a KenPom subscription e-mail and password combination,\n set as the system environment variables KP_USER and KP_PW.", "\n See ?kp_user_pw for details.", call. = FALSE)
browser <- login()
if (!(is.numeric(min_year) && nchar(min_year) == 4 && min_year >= 2002)) {
if (!(is.numeric(min_year) && nchar(min_year) == 4 && min_year >= 2001)) {
# Check if year is numeric, if not NULL
cli::cli_abort("Enter valid min_year as a number (YYYY), data only goes back to 2002")
cli::cli_abort("Enter valid min_ as a number (YYYY), data only goes back to 2001")
}


Expand Down Expand Up @@ -884,9 +884,9 @@ kp_teamstats <- function(min_year, max_year=most_recent_mbb_season()){
expr = {
if (!has_kp_user_and_pw()) stop("This function requires a KenPom subscription e-mail and password combination,\n set as the system environment variables KP_USER and KP_PW.", "\n See ?kp_user_pw for details.", call. = FALSE)
browser <- login()
if (!(is.numeric(min_year) && nchar(min_year) == 4 && min_year >= 2002)) {
if (!(is.numeric(min_year) && nchar(min_year) == 4 && min_year >= 2001)) {
# Check if year is numeric, if not NULL
cli::cli_abort("Enter valid min_year as a number (YYYY), data only goes back to 2002")
cli::cli_abort("Enter valid min_ as a number (YYYY), data only goes back to 2001")
}


Expand Down
13 changes: 6 additions & 7 deletions R/kp_team_tables.R
Expand Up @@ -53,9 +53,9 @@ kp_team_schedule <- function(team, year = 2022){
expr = {
if (!has_kp_user_and_pw()) stop("This function requires a KenPom subscription e-mail and password combination,\n set as the system environment variables KP_USER and KP_PW.", "\n See ?kp_user_pw for details.", call. = FALSE)
browser <- login()
if (!(is.numeric(year) && nchar(year) == 4 && year >= 2002)) {
if (!(is.numeric(year) && nchar(year) == 4 && year >= 2001)) {
# Check if year is numeric, if not NULL
cli::cli_abort("Enter valid year as a number (YYYY), data only goes back to 2002")
cli::cli_abort("Enter valid year as a number (YYYY), data only goes back to 2001")
}

if (!(team %in% hoopR::teams_links$Team)) {
Expand Down Expand Up @@ -517,9 +517,9 @@ kp_gameplan <- function(team, year=2021){
expr = {
if (!has_kp_user_and_pw()) stop("This function requires a KenPom subscription e-mail and password combination,\n set as the system environment variables KP_USER and KP_PW.", "\n See ?kp_user_pw for details.", call. = FALSE)
browser <- login()
if (!(is.numeric(year) && nchar(year) == 4 && year >= 2002)) {
if (!(is.numeric(min_year) && nchar(min_year) == 4 && min_year >= 2001)) {
# Check if year is numeric, if not NULL
cli::cli_abort("Enter valid year as a number (YYYY), data only goes back to 2002")
cli::cli_abort("Enter valid min_ as a number (YYYY), data only goes back to 2001")
}

if (!(team %in% hoopR::teams_links$Team)) {
Expand Down Expand Up @@ -786,10 +786,9 @@ kp_opptracker <- function(team, year = 2021){
expr = {
if (!has_kp_user_and_pw()) stop("This function requires a KenPom subscription e-mail and password combination,\n set as the system environment variables KP_USER and KP_PW.", "\n See ?kp_user_pw for details.", call. = FALSE)
browser <- login()

if (!(is.numeric(year) && nchar(year) == 4 && year >= 2002)) {
if (!(is.numeric(min_year) && nchar(min_year) == 4 && min_year >= 2001)) {
# Check if year is numeric, if not NULL
cli::cli_abort("Enter valid year as a number (YYYY), data only goes back to 2002")
cli::cli_abort("Enter valid min_ as a number (YYYY), data only goes back to 2001")
}

if (!(team %in% hoopR::teams_links$Team)) {
Expand Down

0 comments on commit 8726723

Please sign in to comment.