The batting dataset contains MLB player, salary, and hitting statistics from Sean Lahman's Baseball Database.

batting

Format

A data frame with 9395 observations on 36 variables. The variables are as follows:

playerID

Unique identifier for each player

yearID

Year data was observed

teamID

Team; a factor

stint

Player's stint (order of appearances within season)

lgID

League; a factor with levels AA AL FL NL PL UA

G

Games: number of games in which a player played

AB

At Bats

R

Runs

H

Hits: times reached base because of a batted, fair ball wihtout error by the defense

X2B

Doubles: hits on which the batter reached second base safely

X3B

Triples: hits on which the batter reached third base safely

HR

Homeruns

RBI

Runs Batted In

SB

Stolen Bases

CS

Caught Stealing

BB

Base on Balls

SO

Strikeouts

IBB

Intentional Walks

HBP

Hit by Pitch

SH

Sacrifice Hits

SF

Sacrifice Flies

GIDP

Grounded into Double Plays

BA

Batting Average

PA

Plate Appearances

TB

Total Bases

SlugPct

Slugging Percentage

OBP

On-Base Percentage

OPS

On-Base Percentage + Slugging

BABIP

Batting Average on Balls in Play

salary

Annual Salary

birthYear

Year a player was born

birthMonth

Month a player was born

nameLast

Player's last name

nameFirst

Player's first name

bats

Player's batting hand

age

Player's age

Source

Lahman, S. (2010) Lahman's Baseball Database, 1871-2012, 2012 version, http://www.seanlahman.com/baseball-archive/statistics/.

Details

This dataset combines Lahman's Master, Batting, and Salaries datasets to provide comprehensive batting statistics for each Major League Baseball player. The dataset was reduced to a 15 year time frame (2001-2016) and simplified by removing all incomplete cases.

Author

Shane Ross <saross@wesleyan.edu>

Examples

summary(batting)
#>       playerID        yearID         teamID         stint       lgID     
#>  beltrad01:  16   Min.   :2001   PIT    : 360   Min.   :1.000   AL:4034  
#>  ortizda01:  16   1st Qu.:2004   COL    : 359   1st Qu.:1.000   NL:5361  
#>  pujolal01:  16   Median :2008   ARI    : 350   Median :1.000            
#>  suzukic01:  16   Mean   :2008   PHI    : 348   Mean   :1.002            
#>  beltrca01:  15   3rd Qu.:2012   CIN    : 340   3rd Qu.:1.000            
#>  hudsoti01:  15   Max.   :2016   SFN    : 340   Max.   :3.000            
#>  (Other)  :9301                  (Other):7298                            
#>        G                AB              R                H         
#>  Min.   :  1.00   Min.   :  1.0   Min.   :  0.00   Min.   :  0.00  
#>  1st Qu.: 33.00   1st Qu.: 37.0   1st Qu.:  2.00   1st Qu.:  5.00  
#>  Median : 74.00   Median :183.0   Median : 21.00   Median : 44.00  
#>  Mean   : 79.35   Mean   :236.4   Mean   : 31.66   Mean   : 62.16  
#>  3rd Qu.:128.00   3rd Qu.:429.5   3rd Qu.: 55.00   3rd Qu.:113.00  
#>  Max.   :163.00   Max.   :716.0   Max.   :146.00   Max.   :262.00  
#>                                                                    
#>       X2B             X3B               HR              RBI        
#>  Min.   : 0.00   Min.   : 0.000   Min.   : 0.000   Min.   :  0.00  
#>  1st Qu.: 1.00   1st Qu.: 0.000   1st Qu.: 0.000   1st Qu.:  2.00  
#>  Median : 8.00   Median : 0.000   Median : 3.000   Median : 19.00  
#>  Mean   :12.47   Mean   : 1.255   Mean   : 7.289   Mean   : 30.37  
#>  3rd Qu.:22.00   3rd Qu.: 2.000   3rd Qu.:11.000   3rd Qu.: 52.00  
#>  Max.   :56.00   Max.   :23.000   Max.   :73.000   Max.   :160.00  
#>                                                                    
#>        SB               CS               BB               SO        
#>  Min.   : 0.000   Min.   : 0.000   Min.   :  0.00   Min.   :  0.00  
#>  1st Qu.: 0.000   1st Qu.: 0.000   1st Qu.:  1.00   1st Qu.: 11.00  
#>  Median : 1.000   Median : 0.000   Median : 14.00   Median : 36.00  
#>  Mean   : 4.045   Mean   : 1.589   Mean   : 22.48   Mean   : 46.92  
#>  3rd Qu.: 4.000   3rd Qu.: 2.000   3rd Qu.: 37.00   3rd Qu.: 75.00  
#>  Max.   :78.000   Max.   :24.000   Max.   :232.00   Max.   :223.00  
#>                                                                     
#>       IBB               HBP               SH              SF        
#>  Min.   :  0.000   Min.   : 0.000   Min.   : 0.00   Min.   : 0.000  
#>  1st Qu.:  0.000   1st Qu.: 0.000   1st Qu.: 0.00   1st Qu.: 0.000  
#>  Median :  0.000   Median : 1.000   Median : 1.00   Median : 1.000  
#>  Mean   :  1.848   Mean   : 2.431   Mean   : 2.03   Mean   : 1.921  
#>  3rd Qu.:  2.000   3rd Qu.: 4.000   3rd Qu.: 3.00   3rd Qu.: 3.000  
#>  Max.   :120.000   Max.   :30.000   Max.   :24.00   Max.   :16.000  
#>                                                                     
#>       GIDP              BA               PA              TB        
#>  Min.   : 0.000   Min.   :0.0000   Min.   :  1.0   Min.   :  0.00  
#>  1st Qu.: 0.000   1st Qu.:0.1670   1st Qu.: 42.0   1st Qu.:  6.00  
#>  Median : 4.000   Median :0.2430   Median :204.0   Median : 67.00  
#>  Mean   : 5.438   Mean   :0.2148   Mean   :265.3   Mean   : 99.01  
#>  3rd Qu.: 9.000   3rd Qu.:0.2760   3rd Qu.:480.0   3rd Qu.:177.00  
#>  Max.   :32.000   Max.   :1.0000   Max.   :778.0   Max.   :425.00  
#>                                                                    
#>     SlugPct            OBP             OPS             BABIP       
#>  Min.   :0.0000   Min.   :0.000   Min.   :0.0000   Min.   :0.0000  
#>  1st Qu.:0.2160   1st Qu.:0.214   1st Qu.:0.4350   1st Qu.:0.2250  
#>  Median :0.3610   Median :0.305   Median :0.6690   Median :0.2830  
#>  Mean   :0.3242   Mean   :0.270   Mean   :0.5942   Mean   :0.2622  
#>  3rd Qu.:0.4380   3rd Qu.:0.342   3rd Qu.:0.7760   3rd Qu.:0.3180  
#>  Max.   :2.0000   Max.   :1.000   Max.   :3.0000   Max.   :1.0000  
#>                                                                    
#>      salary           birthYear      birthMonth         nameLast   
#>  Min.   :  165574   Min.   :1958   Min.   : 1.00   Johnson  :  83  
#>  1st Qu.:  480000   1st Qu.:1974   1st Qu.: 4.00   Gonzalez :  81  
#>  Median : 1300000   Median :1978   Median : 7.00   Young    :  63  
#>  Mean   : 3580602   Mean   :1978   Mean   : 6.58   Hernandez:  60  
#>  3rd Qu.: 5000000   3rd Qu.:1983   3rd Qu.:10.00   Perez    :  58  
#>  Max.   :33000000   Max.   :1994   Max.   :12.00   Wilson   :  57  
#>                                                    (Other)  :8993  
#>    nameFirst    bats          age      
#>  Mike   : 216   B:1044   Min.   :20.0  
#>  Chris  : 208   L:2776   1st Qu.:26.0  
#>  Jason  : 195   R:5575   Median :29.0  
#>  Ryan   : 164            Mean   :29.5  
#>  Matt   : 160            3rd Qu.:32.0  
#>  Mark   : 156            Max.   :49.0  
#>  (Other):8296