scrape_bref: Scrapes Batting or Pitching Leaders from Baseball-Reference

Description Usage Arguments Details Value Examples

View source: R/clean-japan.R

Description

Takes the url for a Baseball-References leaderboard and scrapes the data over a specified timeframe

Usage

1
2
scrape_bref(yrs, type = c("bat", "pit"),
  brefBaseURL = "http://www.baseball-reference.com/japan/leader.cgi?type=bat&year=")

Arguments

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.

Details

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.

Value

tbl_df of data scraped from Baseball-Reference.

Examples

1
2
3
4
# batters
x <- scrape_bref(2005:2014)
# pitchers
y <- scrape_bref(2005:2014, type = "pit")

guytuori/simScores documentation built on May 17, 2019, 9:29 a.m.