knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
The latest release of the baseballr
includes a function for acquiring player statistics from the NCAA's website for baseball teams across the three major divisions (I, II, III).
The function, ncaa_scrape
, requires the user to pass values for three parameters for the function to work:
school_id
: numerical code used by the NCAA for each school
year
: a four-digit year
type
: whether to pull data for batters or pitchers
If you want to pull batting statistics for Vanderbilt for the 2013 season, you would use the following:
library(baseballr) library(dplyr) ncaa_scrape(736, 2013, "batting") %>% select(year:OBPct)
The same can be done for pitching, just by changing the type
parameter:
ncaa_scrape(736, 2013, "pitching") %>% select(year:ERA)
Now, the function is dependent on the user knowing the school_id
used by the NCAA website. Given that, I've included a school_id_lu
function so that users can find the school_id
they need.
Just pass a string to the function and it will return possible matches based on the school's name:
school_id_lu("Vand")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.