SchoolsPlayers {Lahman}R Documentation

SchoolsPlayers table

Description

Information on schools players attended, by player

Usage

data(SchoolsPlayers)

Format

A data frame with 6147 observations on the following 4 variables.

playerID

Player ID code

schoolID

school ID code

yearMin

year player's college career started

yearMax

year player's college career ended

Source

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

Examples


data(SchoolsPlayers)
head(SchoolsPlayers)
##    playerID  schoolID yearMin yearMax
## 1 aardsda01    pennst    2001    2001
## 2 aardsda01      rice    2002    2003
## 3 abbeybe01   vermont    1888    1892
## 4 abbotgl01 carkansas    1970    1970
## 5 abbotje01  kentucky    1991    1992
## 6 abbotji01  michigan    1986    1988

## Q: What are the top universities for producing MLB players?
SPcount <- table(SchoolsPlayers$schoolID)
SPcount[SPcount>50]
## 
##    alabama    arizona  arizonast california    florida  floridast 
##         62         66         98         53         54         60 
##    fordham  holycross   illinois        lsu   michigan  notredame 
##         56         75         68         59         77         70 
##   oklahoma santaclara   stanford  stmarysca      texas       ucla 
##         61         54         82         60        100         66 
##      upenn        usc 
##         53        102

library('lattice')
dotplot(SPcount[SPcount>50])

plot of chunk unnamed-chunk-1

dotplot(sort(SPcount[SPcount>50]))

plot of chunk unnamed-chunk-1


## Q: How many schools are represented in this dataset?
length(table(SchoolsPlayers$schoolID))
## [1] 713

# Histogram of the number of players from each school who played in MLB:
with(SchoolsPlayers, hist(table(schoolID), xlab = 'Number of players',
                           main = ""))

plot of chunk unnamed-chunk-1



[Package Lahman version 2.0-1 Index]