AwardsSharePlayers {Lahman} | R Documentation |
Award voting for managers awards
data(AwardsSharePlayers)
A data frame with 6531 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. (2010) Lahman's Baseball Database, 1871-2012, 2012 version, http://baseball1.com/statistics/
# Vote tallies for post-season player awards
require(plyr)
# Which awards are represented in this data frame?
unique(AwardsSharePlayers$awardID)
## [1] "Cy Young" "MVP" "Rookie of the Year"
# 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)
## awardID yearID lgID playerID pointsWon pointsMax votesFirst
## 682 Cy Young 2012 AL priceda01 153 196 14
## 683 Cy Young 2012 AL verlaju01 149 196 13
## 684 Cy Young 2012 AL weaveje02 70 196 0
## 685 Cy Young 2012 AL hernafe02 41 196 0
## 686 Cy Young 2012 AL rodnefe01 38 196 1
## 687 Cy Young 2012 AL salech01 17 196 0
## 688 Cy Young 2012 AL johnsji04 5 196 0
## 689 Cy Young 2012 AL harrima01 2 196 0
## 690 Cy Young 2012 AL darviyu01 1 196 0
## 691 Cy Young 2012 NL dickera01 209 224 27
## 692 Cy Young 2012 NL kershcl01 96 224 2
## 693 Cy Young 2012 NL gonzagi01 93 224 1
## 694 Cy Young 2012 NL cuetojo01 75 224 1
## 695 Cy Young 2012 NL kimbrcr01 41 224 1
## 696 Cy Young 2012 NL cainma01 22 224 0
## 697 Cy Young 2012 NL lohseky01 6 224 0
## 698 Cy Young 2012 NL chapmar01 1 224 0
## 699 Cy Young 2012 NL hamelco01 1 224 0
# 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)
## awardID yearID lgID playerID pointsWon pointsMax votesFirst
## 25 Cy Young 1963 ML koufasa01 20 20 20
## 29 Cy Young 1965 ML koufasa01 20 20 20
## 30 Cy Young 1966 ML koufasa01 20 20 20
## 36 Cy Young 1968 AL mclaide01 20 20 20
## 37 Cy Young 1968 NL gibsobo01 20 20 20
## 84 Cy Young 1972 NL carltst01 120 120 24
## 175 Cy Young 1978 AL guidrro01 140 140 28
## 282 Cy Young 1984 NL sutclri01 120 120 24
## 298 Cy Young 1985 NL goodedw01 120 120 24
## 305 Cy Young 1986 AL clemero02 140 140 28
## 342 Cy Young 1988 NL hershor01 120 120 24
## 427 Cy Young 1994 NL maddugr01 140 140 28
## 441 Cy Young 1995 NL maddugr01 140 140 28
## 476 Cy Young 1998 AL clemero02 140 140 28
## 487 Cy Young 1999 AL martipe02 140 140 28
## 505 Cy Young 2000 AL martipe02 140 140 28
## 533 Cy Young 2002 NL johnsra05 160 160 32
## 551 Cy Young 2004 AL santajo01 140 140 28
## 579 Cy Young 2006 AL santajo01 140 140 28
## 602 Cy Young 2007 NL peavyja01 160 160 32
## 646 Cy Young 2010 NL hallaro01 224 224 32
## 659 Cy Young 2011 AL verlaju01 196 196 28
# Top five pitchers with most top 3 vote tallies in CYA
head(with(cya_top3, rev(sort(table(playerID)))), 5)
## playerID
## clemero02 johnsra05 maddugr01 palmeji01 martipe02
## 10 9 7 6 6
# 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)
## playerID
## bondsba01 pujolal01 willite01 musiast01 mantlmi01
## 9 8 7 7 7