# Voting for the BBWAA Manager of the Year award by year and league
require(plyr)
# Sort in decreasing order of points by year and league
MOYsort <- ddply(AwardsShareManagers, .(yearID, lgID), arrange, desc(pointsWon))
# Any unanimous winners?
subset(AwardsShareManagers, pointsWon == pointsMax)
# OK, how about highest proportion of possible points?
AwardsShareManagers[with(AwardsShareManagers, which.max(pointsWon/pointsMax)), ]
# Bobby Cox's MOY vote tallies
subset(AwardsShareManagers, playerID == "coxbo01")
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(Lahman)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/Lahman/AwardsShareManagers.Rd_%03d_medium.png", width=480, height=480)
> ### Name: AwardsShareManagers
> ### Title: AwardsShareManagers table
> ### Aliases: AwardsShareManagers
> ### Keywords: datasets
>
> ### ** Examples
>
> # Voting for the BBWAA Manager of the Year award by year and league
>
> require(plyr)
Loading required package: plyr
>
> # Sort in decreasing order of points by year and league
> MOYsort <- ddply(AwardsShareManagers, .(yearID, lgID), arrange, desc(pointsWon))
>
> # Any unanimous winners?
> subset(AwardsShareManagers, pointsWon == pointsMax)
[1] awardID yearID lgID playerID pointsWon pointsMax votesFirst
<0 rows> (or 0-length row.names)
>
> # OK, how about highest proportion of possible points?
> AwardsShareManagers[with(AwardsShareManagers, which.max(pointsWon/pointsMax)), ]
awardID yearID lgID playerID pointsWon pointsMax votesFirst
87 Mgr of the year 1991 AL kellyto01 138 140 27
>
> # Bobby Cox's MOY vote tallies
> subset(AwardsShareManagers, playerID == "coxbo01")
awardID yearID lgID playerID pointsWon pointsMax votesFirst
2 Mgr of the year 1983 AL coxbo01 4 28 4
9 Mgr of the year 1984 AL coxbo01 9 140 0
17 Mgr of the year 1985 AL coxbo01 104 140 16
95 Mgr of the year 1991 NL coxbo01 96 120 13
105 Mgr of the year 1992 NL coxbo01 29 120 1
120 Mgr of the year 1993 NL coxbo01 27 140 0
132 Mgr of the year 1994 NL coxbo01 3 140 0
147 Mgr of the year 1995 NL coxbo01 20 140 1
163 Mgr of the year 1996 NL coxbo01 24 140 3
174 Mgr of the year 1997 NL coxbo01 6 140 0
189 Mgr of the year 1998 NL coxbo01 17 160 0
198 Mgr of the year 1999 NL coxbo01 98 160 10
214 Mgr of the year 2000 NL coxbo01 41 160 1
228 Mgr of the Year 2001 NL coxbo01 12 160 2
238 Mgr of the Year 2002 NL coxbo01 93 160 9
253 Mgr of the Year 2003 NL coxbo01 56 160 6
264 Mgr of the year 2004 NL coxbo01 140 160 22
276 Mgr of the year 2005 NL coxbo01 152 160 28
327 Mgr of the year 2009 NL coxbo01 15 160 0
342 Mgr of the year 2010 NL coxbo01 28 160 1
>
>
>
>
>
>
> dev.off()
null device
1
>