clean_PIA: Some Basic Cleaning on Data Downloaded from PIA

Description Usage Arguments Details Value Examples

View source: R/clean-data.R

Description

This function changes column names of batting and pitching data downloaded from PIA. It also changes some of the labels, and removes rows where player did not record a plate appearance. Finally, it ensures that player played in levels for which we have MLEs.

Usage

1
clean_PIA(minors, majors, okay_levels = c("High_A", "AA", "AAA", "MLB"))

Arguments

minors

is a data.frame with the statistics from the minors that have been download from PIA.

okay_levels

the levels for which we wish to calculate MLEs. Any observations which aren't at these levels are removed. Defaults to c("High_A", "AA", "AAA", "MLB").

minors

is a data.frame with the statistics from the minors that have been download from PIA.

Details

Changes column names, names of levels, and name of Florida organization to make typing easier. For example, "Level.of.Play.Name.Abbrev" is changed to "Level." Then removes any rows where the batter recorded 0 PA or the pitcher has 0 batters faced.

Value

tbl_df of cleaned statistics

Examples

1
2
3
4
5
6
7
curr_wd <- getwd()
setwd("N:/Apps/simScoresApp/data")
min <- read.csv("0-downloads/bat_minors2.csv", header = T, stringsAsFactors = F) %>% tbl_df()
maj <- read.csv("0-downloads/bat_majors2.csv", header = T, stringsAsFactors = F) %>% tbl_df()
x <- clean_PIA(min, maj)
x
setwd(curr_wd)

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