This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# read in three packages | |
library(readr) | |
library(dplyr) | |
library(ggplot2) | |
# helper ggplot2 function | |
helper_ggplot <- function(){ | |
theme(text=element_text(size=18)) + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# load in packages | |
library(readr) | |
library(dplyr) | |
library(lme4) | |
library(ggplot2) | |
library(posterior) | |
library(gridExtra) | |
library(Lahman) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# load in packages | |
library(readr) | |
library(dplyr) | |
library(brms) | |
library(ggplot2) | |
library(posterior) | |
library(gridExtra) | |
library(Lahman) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# preparation work for FanGraphs leaderboard data | |
# collected FanGraphs Leaderboard batting data | |
# choose Multiple Seasons (all), Split Seasons | |
# minimum 100 PA in each season | |
# download data and saved as "fgbatting.csv" | |
library(dplyr) | |
library(readr) | |
library(Lahman) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(ggplot2) | |
library(dplyr) | |
library(readr) | |
# read in Retrosheet data for two seasons | |
d <- read_csv("retro_2seasons_ip.csv") | |
# main drawing function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "AVG on Ground Balls" | |
author: "Jim Albert" | |
date: "11/2/2021" | |
output: html_document | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(echo = TRUE, | |
message = FALSE, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
perfect <- function(d, n_innings){ | |
# inputs are Retrosheet play-by-play data frame d and | |
# number of innings n_innings | |
# output is a data frame containing all Perfect-k | |
# games for that season | |
require(dplyr) | |
d %>% | |
mutate(PIT_ID = as.character(PIT_ID), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# required packages | |
library(dplyr) | |
library(ggplot2) | |
library(readr) | |
library(lubridate) | |
library(stringr) | |
# some helper functions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
retro_streakwork <- function(retrodata){ | |
find_streaks_retro <- function(playerid, retrodata){ | |
require(lubridate) | |
require(dplyr) | |
require(purrr) | |
retrodata %>% | |
mutate(Date = ymd(substr(GAME_ID, 4, 11)), | |
Game = as.numeric(substr(GAME_ID, 12, 12))) %>% | |
filter(BAT_ID == playerid, | |
AB_FL == TRUE) %>% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(readr) | |
library(dplyr) | |
library(ggplot2) | |
sc_pitcher_2019 <- read_delim( | |
"https://raw.githubusercontent.com/bayesball/ShinyBaseball/main/data/sc_pitcher_2019.txt", | |
delim = " ") | |
ui <- fluidPage( |