BillPetti / baseballr

A package written for R focused on baseball analysis. Currently in development.
billpetti.github.io/baseballr
Other
369 stars 99 forks source link

Updates to Prep for CRAN #210

Closed saiemgilani closed 3 years ago

saiemgilani commented 3 years ago

1. Some GitHub workflow updates

2. An attempt at updating some documented datasets and documentation

3. Do it for the CRAN

4. Tests (work in progress)

Boils down to vizzes and model prep code. If it's written outside the pipeline and there isn't a convenience function, it'd take me more time than I'd care to in order to figure out what goes where.

5. Substantive code change to fix small issues or simplify

6. Package Documentation and Website details

BillPetti commented 3 years ago

Still working through, but to your question about gh-pages--that's where I used to host a site about the package. Now it is built through pkgdown and is built in the docs folder on the master branch.

BillPetti commented 3 years ago

I'm gonna merge this into my dev branch and then let's see how it works. My guess is we've got some other work to do as I've made some bug fixes to the master since these were pushed, etc.

BillPetti commented 3 years ago

@saiemgilani

So I ran a check on the dev branch and here's what I got:

── R CMD check results ──────────────────────────────────── baseballr 0.9.9 ────
Duration: 2m 51.8s

> checking tests ...
  See below...

> checking dependencies in R code ... NOTE
  Missing or unexported object: ‘rvest::html_elements’

> checking R code for possible problems ... NOTE
  get_ncaa_lineups: no visible binding for global variable ‘playerName’
  Undefined global functions or variables:
    playerName

── Test failures ───────────────────────────────────────────────── testthat ────

> library(testthat)
> library(baseballr)
> 
> test_check("baseballr")
[1] "Be patient, this may take a few seconds..."
[1] "Data courtesy of the Chadwick Bureau Register (https://github.com/chadwickbureau/register)"
[1] "Be patient, this may take a few seconds..."
[1] "Data courtesy of the Chadwick Bureau Register (https://github.com/chadwickbureau/register)"
[1] "Be patient, this may take a few seconds..."
[1] "Data courtesy of the Chadwick Bureau Register (https://github.com/chadwickbureau/register)"
[1] "Be patient, this may take a few seconds..."
[1] "Data courtesy of the Chadwick Bureau Register (https://github.com/chadwickbureau/register)"
══ Failed tests ════════════════════════════════════════════════════════════════
── Error (test-batter_game_logs_fg.R:11:3): Fangraphs Batter Game Logs ─────────
Error: 'html_elements' is not an exported object from 'namespace:rvest'
Backtrace:
    █
 1. ├─baseballr::batter_game_logs_fg(playerid = 6184, year = 2017) test-batter_game_logs_fg.R:11:2
 2. │ ├─`%>%`(...)
 3. │ └─xml2::read_html(url) %>% rvest::html_elements("table")
 4. ├─base::as.data.frame(.)
 5. ├─rvest::html_table(., fill = TRUE)
 6. └─rvest::html_elements
 7.   └─base::getExportedValue(pkg, name)
── Error (test-get_ncaa_baseball_roster.R:11:3): NCAA Get Roster ───────────────
Error: Table has inconsistent number of columns. Do you want fill = TRUE?
Backtrace:
    █
 1. ├─baseballr::get_ncaa_baseball_roster(teamid = 104, team_year = 2019) test-get_ncaa_baseball_roster.R:11:2
 2. │ └─(payload %>% rvest::html_nodes("table"))[[1]] %>% rvest::html_table()
 3. ├─rvest::html_table(.)
 4. └─rvest:::html_table.xml_node(.)
── Error (test-milb_batter_game_logs_fg.R:16:3): FanGraphs MiLB Batter Game Logs ──
Error: 'html_elements' is not an exported object from 'namespace:rvest'
Backtrace:
    █
 1. ├─baseballr::milb_batter_game_logs_fg(playerid = "sa917940", year = 2018) test-milb_batter_game_logs_fg.R:16:2
 2. │ ├─`%>%`(...)
 3. │ └─xml2::read_html(url_adv) %>% rvest::html_elements("table#SeasonStats1_dgSeason2_ctl00")
 4. ├─base::as.data.frame(.)
 5. ├─rvest::html_table(.)
 6. └─rvest::html_elements
 7.   └─base::getExportedValue(pkg, name)
saiemgilani commented 3 years ago

@saiemgilani

So I ran a check on the dev branch and here's what I got:

── R CMD check results ──────────────────────────────────── baseballr 0.9.9 ────
Duration: 2m 51.8s

> checking tests ...
  See below...

> checking dependencies in R code ... NOTE
  Missing or unexported object: ‘rvest::html_elements’

> checking R code for possible problems ... NOTE
  get_ncaa_lineups: no visible binding for global variable ‘playerName’
  Undefined global functions or variables:
    playerName

── Test failures ───────────────────────────────────────────────── testthat ────

> library(testthat)
> library(baseballr)
> 
> test_check("baseballr")
[1] "Be patient, this may take a few seconds..."
[1] "Data courtesy of the Chadwick Bureau Register (https://github.com/chadwickbureau/register)"
[1] "Be patient, this may take a few seconds..."
[1] "Data courtesy of the Chadwick Bureau Register (https://github.com/chadwickbureau/register)"
[1] "Be patient, this may take a few seconds..."
[1] "Data courtesy of the Chadwick Bureau Register (https://github.com/chadwickbureau/register)"
[1] "Be patient, this may take a few seconds..."
[1] "Data courtesy of the Chadwick Bureau Register (https://github.com/chadwickbureau/register)"
══ Failed tests ════════════════════════════════════════════════════════════════
── Error (test-batter_game_logs_fg.R:11:3): Fangraphs Batter Game Logs ─────────
Error: 'html_elements' is not an exported object from 'namespace:rvest'
Backtrace:
    █
 1. ├─baseballr::batter_game_logs_fg(playerid = 6184, year = 2017) test-batter_game_logs_fg.R:11:2
 2. │ ├─`%>%`(...)
 3. │ └─xml2::read_html(url) %>% rvest::html_elements("table")
 4. ├─base::as.data.frame(.)
 5. ├─rvest::html_table(., fill = TRUE)
 6. └─rvest::html_elements
 7.   └─base::getExportedValue(pkg, name)
── Error (test-get_ncaa_baseball_roster.R:11:3): NCAA Get Roster ───────────────
Error: Table has inconsistent number of columns. Do you want fill = TRUE?
Backtrace:
    █
 1. ├─baseballr::get_ncaa_baseball_roster(teamid = 104, team_year = 2019) test-get_ncaa_baseball_roster.R:11:2
 2. │ └─(payload %>% rvest::html_nodes("table"))[[1]] %>% rvest::html_table()
 3. ├─rvest::html_table(.)
 4. └─rvest:::html_table.xml_node(.)
── Error (test-milb_batter_game_logs_fg.R:16:3): FanGraphs MiLB Batter Game Logs ──
Error: 'html_elements' is not an exported object from 'namespace:rvest'
Backtrace:
    █
 1. ├─baseballr::milb_batter_game_logs_fg(playerid = "sa917940", year = 2018) test-milb_batter_game_logs_fg.R:16:2
 2. │ ├─`%>%`(...)
 3. │ └─xml2::read_html(url_adv) %>% rvest::html_elements("table#SeasonStats1_dgSeason2_ctl00")
 4. ├─base::as.data.frame(.)
 5. ├─rvest::html_table(.)
 6. └─rvest::html_elements
 7.   └─base::getExportedValue(pkg, name)

You're not using rvest >= 1.0.0 is why, I'm guessing. The ' fill' parameter was deprecated in html_table (it just does a better job, it's not necessary anymore), and html_elements is essentially a drop-in replacement for html_node.

I have been trying to update the pull to match the other branches as they've happened, so I'm hoping it is minimal.

For example, I commited a CRAN-passable version of the statcast payload and fixed the milb funcs. b71e21c b3f5f96