Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slight change to parsing Ken Pom Data #14

Open
meysubb opened this issue Mar 21, 2019 · 2 comments
Open

Slight change to parsing Ken Pom Data #14

meysubb opened this issue Mar 21, 2019 · 2 comments

Comments

@meysubb
Copy link

meysubb commented Mar 21, 2019

Looks like readr::parse_number has changed a bit. It now expects a character before converting.

I would make a PR, but I forked into a repo of mine instead of a stand-alone fork. Thanks for providing these resources!

Made a slight change to your parsing function to handle that. The solution is as follows:

process_ken_pom_sheet <- function(dat){
  dat <- dat %>%
    clean_names() %>%
    mutate(seed = str_extract(x2, "[0-9]+")) %>% # extract seed where applicable
    mutate(x2 = gsub(" [0-9]+", "", x2)) # remove seed from school name
  names(dat) <- c("rank", "team", "conf", "wins_losses",
                  "adj_EM", "adj_offensive_efficiency", "adj_offensive_efficiency_seed",
                  "adj_defensive_efficiency", "adj_defensive_efficiency_seed",
                  "adj_tempo", "adj_tempo_seed", "luck", "luck_seed", "sos_adj_em",
                  "sos_adj_em_seed", "opposing_offenses", "opposing_offenses_seed",
                  "opposing_defenses", "opposing_defenses_seed", "ncsos_adj_em",
                  "ncsos_adj_em_seed", "year", "seed")
  
  dat <- dat[-1, ] %>%
    select(rank, everything()) %>%
    filter(!is.na(rank), !rank %in% c("Rank", "Rk")) %>%
    mutate(rank = as.numeric(rank)) %>%
    mutate_all(as.character) %>% 
    mutate_at(vars(adj_EM:year), parse_number) %>%
    mutate(seed = as.numeric(seed))
  dat
}
@sfirke
Copy link
Owner

sfirke commented Mar 21, 2019

thanks for pointing this out! I must have fixed this on my other machine and not pushed the changes? Or else... maybe it failed and I didn't notice and I made predictions using last year's KP data, hehe. I will check later and incorporate your addition if needed. Good luck on Kaggle!

@sfirke sfirke added the bug label Mar 21, 2019
@sfirke
Copy link
Owner

sfirke commented Feb 28, 2023

I don't have the bandwidth to compete this year but can merge pull requests if anyone wants to patch this or make other updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants