Getting Started with baseballr"

knitr::opts_chunk$set(echo = TRUE)
# You can install using the pacman package using the following code:
# if (!requireNamespace('pacman', quietly = TRUE)){
#   install.packages('pacman')
# }
# pacman::p_load_current_gh("r-lib/pkgapi")
# library(pkgapi)
# pkg <- pkgapi::map_package(path = "../")
# library(dplyr)
# function_calls <- pkg$calls
# exported <- pkg$defs %>% 
#   dplyr::filter(exported == TRUE) %>% 
#   dplyr::select(all_of(c("name", "file"))) 
# 
# mlb_functions <- exported %>% 
#   dplyr::filter(stringr::str_detect(.data$name,pattern = "^mlb_*"))
# 
# bref_functions <- exported %>% 
#   dplyr::filter(stringr::str_detect(.data$name,pattern = "^bref_*"))
# fg_functions <- exported %>% 
#   dplyr::filter(stringr::str_detect(.data$name,pattern = "^fg_*"))
# sc_functions <- exported %>% 
#   dplyr::filter(stringr::str_detect(.data$name,pattern = "^statcast_*"))
# ncaa_functions <- exported %>% 
#   dplyr::filter(stringr::str_detect(.data$name,pattern = "^ncaa_*"))
# chadwick_functions <- exported %>% 
#   dplyr::filter(stringr::str_detect(.data$name,pattern = "^chadwick_*|^playerid_*|^playername_*"))
# retrosheet_functions <- exported %>% 
#   dplyr::filter(stringr::str_detect(.data$name,pattern = "^retrosheet_*"))
old <- options(rmarkdown.html_vignette.check_title = FALSE)
pkg_name <- "billpetti/baseballr"
url <- paste0("https://raw.githubusercontent.com/", pkg_name, "/master/DESCRIPTION")
x <- readLines(url)
remote_version <- gsub("Version:\\s*", "", x[grep('Version:', x)])

Welcome folks,

I'm Saiem Gilani, one of the authors of baseballr, and I hope to give the community a high-quality resource for accessing men's baseball data for statistical analysis, baseball research, and more. I am excited to show you some of what you can do with this edition of the package.

Installing R and RStudio

  1. Head to https://cran.r-project.org
  2. Select the appropriate link for your operating system (Windows, Mac OS X, or Linux)

  3. Windows - Select base and download the most recent version

  4. Mac OS X - Select Latest Release, but check to make sure your OS is the correct version. Look through Binaries for Legacy OS X Systems if you are on an older release
  5. Linux - Select the appropriate distro and follow the installation instructions

  6. Head to RStudio.com

  7. Follow the associated download and installation instructions for RStudio.
  8. Start peering over the RStudio IDE Cheatsheet. An IDE is an integrated development environment.
  9. For Windows users: I recommend you install Rtools. This is not an R package! It is “a collection of resources for building packages for R under Microsoft Windows, or for building R itself”. Go to https://cran.r-project.org/bin/windows/Rtools/ and follow the directions for installation.

Install baseballr

# You can install using the pacman package using the following code:
if (!requireNamespace('pacman', quietly = TRUE)){
  install.packages('pacman')
}
pacman::p_load_current_gh("billpetti/baseballr")

The Data

There are generally speaking eight men's baseball data sources accessible from this package:

Function names indicate the data source

As of baseballr v1.0.0, a function naming convention was implemented to have the data source indicator appear at the start of the function name:

Follow the SportsDataverse on Twitter and star this repo

Twitter Follow

GitHub stars

Our Authors



Try the baseballr package in your browser

Any scripts or data that you put into this service are public.

baseballr documentation built on April 1, 2023, 12:12 a.m.