Description Usage Format Source Examples
Award voting for managers awards
1 |
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
Lahman, S. (2014) Lahman's Baseball Database, 1871-2013, 2014 version, http://baseball1.com/statistics/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | # 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.