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
bin_FF_locations <- function(sc, plateX, plateZ){ | |
# inputs: | |
# ------------------------------------ | |
# sc - statcast data with variables plate_x, | |
# plate_z, description, stand, type, events | |
# plateX = c(plateX_lo, plateX_hi, width_X) | |
# plateZ = c(plateZ_lo, plateZ_hi, width_Z) | |
require(dplyr) | |
# compute number of FF pitches thrown to each side |
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
radial_plot <- function(sc, title = ""){ | |
# NOTE: the graphics file player.png should be | |
# in the same folder as this function | |
# But function will still work without an | |
# error if the graphics file is missing | |
# load in packages and turn off warnings | |
require(latex2exp) | |
require(ggplot2) | |
require(patchwork) |
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: "TTTO" | |
author: "Jim Albert" | |
date: "3/23/2021" | |
output: html_document | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(echo = TRUE, | |
warning = 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
re_offspeed <- function(sc, pside, PT, Nmin){ | |
require(CalledStrike) | |
require(mgcv) | |
require(dplyr) | |
require(ggplot2) | |
require(gammit) | |
# collect number of offspeed pitches for each | |
# pitcher of that particular side | |
sc %>% | |
filter(p_throws == pside) %>% |
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) | |
sc2019_ip <- read.table("https://raw.githubusercontent.com/bayesball/CalledStrike/master/data/sc2019_ip.txt", | |
header = TRUE) | |
ui <- fluidPage( | |
h2("Brushing In-Play Batting Averages"), | |
textInput("name", "Batter Name:", value = ""), |
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: "Computing Pitch Values" | |
author: "Jim Albert" | |
date: "1/15/2021" | |
output: html_document | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(echo = TRUE, | |
warning = 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
setup_work <- function(d2015){ | |
# d2015 is a Retrosheet play by play dataset | |
# removes all non-pitches from PITCH_SEQ_TX | |
d2015$pseq <- gsub("[.>123N+*]", "", d2015$PITCH_SEQ_TX) | |
# create a b and s sequence | |
d2015$pseq <- gsub("[BIPV]", "b", d2015$pseq) | |
d2015$pseq <- gsub("[CFKLMOQRST]", "s", d2015$pseq) | |
one.string3 <- function(ex, count){ |
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
# here are the packages I'm using | |
# CalledStrike depends on other packages | |
library(CalledStrike) | |
library(readr) | |
library(dplyr) | |
library(ggplot2) | |
# read in Statcast data for the 2019 season |
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: "Some Density Estimates" | |
output: | |
html_document: | |
df_print: paged | |
--- | |
```{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
--- | |
title: "tabyls" | |
author: "Jim Albert" | |
date: "10/27/2020" | |
output: html_document | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(echo = TRUE, | |
warning = FALSE, |