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

cleanup to get closer to CRAN submission #75

Merged
merged 21 commits into from Jun 21, 2018

Conversation

beanumber
Copy link
Contributor

Nothing really substantive here -- just bringing things in line with CRAN policy/practice

@beanumber
Copy link
Contributor Author

beanumber commented Jun 20, 2018

d0d98f4 is more substantive. It makes scrape_statcast_savant() as S3 generic, which should help with handling the user input of dates.

@beanumber
Copy link
Contributor Author

Note that readr::read_csv() instead of utils::read.csv() is both faster, and makes better decisions about variable types. I was able to cut out a lot of the type processing by just using the read_csv() defaults.

Copy link
Owner

@BillPetti BillPetti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This took me less time than I thought. Overall, it looks good. There are one or two changes I'm less familiar with, but trust what you've done. Did have one suggested change to the scrape_statcast_savant.Date function to make sure users can pull games regardless of category (i.e. regular season, post season, etc.).

playerid_var <- ifelse(player_type == "pitcher",
"pitchers_lookup%5B%5D", "batters_lookup%5B%5D")

vars <- tibble::tribble(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added to the tibble that is created. This allows for any games to be included, including post season and spring training. Some fields may be unnecessary, but added just in case.

vars <- tibble::tribble(
  ~var, ~value, 
  "all", "true",
  "hfPT", "", 
  "hfAB", "", 
  "hfBBT", "", 
  "hfPR", "", 
  "hfZ", "", 
  "stadium", "", 
  "hfBBL", "", 
  "hfNewZones", "",
  "hfGT", "R%7CPO%7CS%7C&hfC",
  "hfSea", paste0(lubridate::year(start_date), "%7C"),
  "hfSit", "", 
  "hfOuts", "", 
  "opponent", "", 
  "pitcher_throws", "", 
  "batter_stands", "", 
  "hfSA", "", 
  "player_type", player_type,
  "game_date_gt", as.character(start_date),
  "game_date_lt", as.character(end_date),
  "hfInfield", "", 
  "team", "", 
  "position", "", 
  "hfOutfield", "", 
  "hfRO", "", 
  "home_road", "",
  "pitchers_lookup%5B%5D", ifelse(is.null(592789), "", 592789), 
  "hfFlag", "", 
  "hfPull", "", 
  "metric_1", "", 
  "hfInn", "", 
  "min_pitches", 0,
  "min_results", 0,
  "group_by", "name",
  "sort_col", "pitches",
  "player_event_sort", "h_launch_speed",
  "sort_order", "desc",
  "min_abs", 0,
  "type", "details"
) %>%
  dplyr::mutate_(pairs = ~paste(var, "=", value, sep = ""))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but what is this about?

  "pitchers_lookup%5B%5D", ifelse(is.null(592789), "", 592789), 

Copy link
Contributor Author

@beanumber beanumber Jun 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess ultimately it would be cool if users could pass values for all of these values through the .... Or maybe the function could take a params list?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I literally kept telling myself "make sure to copy the right one, make sure to copy the right one".

Re: all the values, yeah that was my thought. Figured it was worth putting them all in now.

@BillPetti BillPetti merged commit 0a28d11 into BillPetti:master Jun 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants