Learn R Programming

Lahman (version 4.0-1)

AwardsSharePlayers: AwardsSharePlayers table

Description

Award voting for managers awards

Usage

data(AwardsSharePlayers)

Arguments

Format

A data frame with 6617 observations on the following 7 variables.
awardID
name of award votes were received for
yearID
Year
lgID
League; a factor with levels AL ML NL
playerID
Player ID code
pointsWon
Number of points received
pointsMax
Maximum numner of points possible
votesFirst
Number of first place votes

Source

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

Examples

Run this code
# Vote tallies for post-season player awards

require(plyr)

# Which awards are represented in this data frame?
unique(AwardsSharePlayers$awardID)

# Sort the votes for the Cy Young award in decreasing order.
# For the first few years, the award went to the best pitcher
# in both leagues.

cyvotes <- ddply(subset(AwardsSharePlayers, awardID == "Cy Young"),
                 .(yearID, lgID), arrange, desc(pointsWon))

# 2012 votes
subset(cyvotes, yearID == 2012)

# top three votegetters each year by league

cya_top3 <- ddply(cyvotes, .(yearID, lgID), function(d) head(d, 3))

# unanimous Cy Young winners
subset(cyvotes, pointsWon == pointsMax)

# Top five pitchers with most top 3 vote tallies in CYA
head(with(cya_top3, rev(sort(table(playerID)))), 5)

# Ditto for MVP awards

MVP <- subset(AwardsSharePlayers, awardID == "MVP")
MVP_top3 <- ddply(MVP, .(yearID, lgID), 
                  function(d) head(arrange(d, desc(pointsWon)), 3))
head(with(MVP_top3, rev(sort(table(playerID)))), 5)

Run the code above in your browser using DataLab