Description Usage Arguments Details Value Examples
Takes the url for a Baseball-References leaderboard and scrapes the data over a specified timeframe
1 2 | scrape_bref(yrs, type = c("bat", "pit"),
brefBaseURL = "http://www.baseball-reference.com/japan/leader.cgi?type=bat&year=")
|
yrs |
numeric. Vector of the years to scrape the data from |
type |
Whether to scrape batting or pitching data. Defaults to batting |
bref_base_url |
character containing the url with the correct Baseball-Reference leaderboard. Defaults to Japanese leaders. |
Pastes yrs
to the end of brefBaseURL
to create a
vectors of urls. Then scrapes the first table at each of these urls using
readHTMLTable
. Then binds the table for each year using
rbind_all
and returns these stacked tables as a
tbl_df
object.
tbl_df
of data scraped from Baseball-Reference.
1 2 3 4 | # batters
x <- scrape_bref(2005:2014)
# pitchers
y <- scrape_bref(2005:2014, type = "pit")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.