Skip to contents

Data on player appearances

Usage

data(Appearances)

Format

A data frame with 113720 observations on the following 21 variables.

yearID

Year

teamID

Team; a factor

lgID

League; a factor with levels AA AL FL NL PL UA

playerID

Player ID code

G_all

Total games played

GS

Games started

G_batting

Games in which player batted

G_defense

Games in which player appeared on defense

G_p

Games as pitcher

G_c

Games as catcher

G_1b

Games as firstbaseman

G_2b

Games as secondbaseman

G_3b

Games as thirdbaseman

G_ss

Games as shortstop

G_lf

Games as leftfielder

G_cf

Games as centerfielder

G_rf

Games as right fielder

G_of

Games as outfielder

G_dh

Games as designated hitter

G_ph

Games as pinch hitter

G_pr

Games as pinch runner

Details

The Appearances table in the original version has some incorrect variable names. In particular, the 5th column is career_year.

Source

Lahman, S. (2024) Lahman's Baseball Database, 1871-2023, 2024 version, http://www.seanlahman.com/

Examples

data(Appearances)
library("dplyr")
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library("tidyr")

# Henry Aaron's last two years as a DH in Milwaukee
Appearances %>%
   filter(playerID == "aaronha01" & teamID == "ML4") %>%
   select(yearID:G_batting, G_of:G_ph)  # subset variables
#>   yearID teamID lgID  playerID G_all  GS G_batting G_of G_dh G_ph
#> 1   1975    ML4   AL aaronha01   137 129       137    3  127    8
#> 2   1976    ML4   AL aaronha01    85  70        85    1   74   15
   
# Herb Washington, strictly a pinch runner for Oakland in 1974-5
Appearances %>%
   filter(playerID == "washihe01") 
#>   yearID teamID lgID  playerID G_all GS G_batting G_defense G_p G_c G_1b G_2b
#> 1   1974    OAK   AL washihe01    92  0        92         0   0   0    0    0
#> 2   1975    OAK   AL washihe01    13  0        13         0   0   0    0    0
#>   G_3b G_ss G_lf G_cf G_rf G_of G_dh G_ph G_pr
#> 1    0    0    0    0    0    0   28    0   92
#> 2    0    0    0    0    0    0    3    0   13

# A true utility player - Jerry Hairston, Jr.
Appearances %>%
  filter(playerID == "hairsje02")
#>    yearID teamID lgID  playerID G_all  GS G_batting G_defense G_p G_c G_1b G_2b
#> 1    1998    BAL   AL hairsje02     6   2         6         4   0   0    0    4
#> 2    1999    BAL   AL hairsje02    50  49        50        50   0   0    0   50
#> 3    2000    BAL   AL hairsje02    49  49        49        49   0   0    0   49
#> 4    2001    BAL   AL hairsje02   159 154       159       156   0   0    0  156
#> 5    2002    BAL   AL hairsje02   122 118       122       119   0   0    0  119
#> 6    2003    BAL   AL hairsje02    58  56        58        48   0   0    0   48
#> 7    2004    BAL   AL hairsje02    86  80        86        62   0   0    0   12
#> 8    2005    CHN   NL hairsje02   114  91       114       104   0   0    0   44
#> 9    2006    CHN   NL hairsje02    38  21        38        32   0   0    1   24
#> 10   2006    TEX   AL hairsje02    63  24        63        56   0   0    0    1
#> 11   2007    TEX   AL hairsje02    73  41        73        71   0   0    0   16
#> 12   2008    CIN   NL hairsje02    80  62        80        71   0   0    0    7
#> 13   2009    CIN   NL hairsje02    86  77        86        81   0   0    0    9
#> 14   2009    NYA   AL hairsje02    45  21        45        41   0   0    0    3
#> 15   2010    SDN   NL hairsje02   119 105       119       114   0   0    0   47
#> 16   2011    MIL   NL hairsje02    45  32        45        40   0   0    0   27
#> 17   2011    WAS   NL hairsje02    75  60        75        72   0   0    0    3
#> 18   2012    LAN   NL hairsje02    78  63        78        74   0   0    1   30
#> 19   2013    LAN   NL hairsje02    96  43        96        63   0   0   13    1
#>    G_3b G_ss G_lf G_cf G_rf G_of G_dh G_ph G_pr
#> 1     0    0    0    0    0    0    0    0    3
#> 2     0    0    0    0    0    0    0    0    1
#> 3     0    0    0    0    0    0    0    0    0
#> 4     0    0    0    0    0    0    0    0    3
#> 5     0    0    0    0    0    0    0    2    2
#> 6     0    0    0    0    0    0    9    1    1
#> 7     1    0   10   15   27   52   21    2    3
#> 8     0    1   20   48    1   62    0   15    1
#> 9     0    0    3    0    5    8    0    7    2
#> 10    1    3   35   12    7   52    3    4   13
#> 11   10    2   21   22    6   49    0    6    5
#> 12    1   34   24   17   12   42    0   10    0
#> 13   33   31    9    3    5   17    0    7    0
#> 14   16   11   10    2    9   19    3    4    8
#> 15    3   62    4    0    8   12    0    7    1
#> 16    5    1    1   11    0   12    0    5    2
#> 17   44    1   22    9    0   30    0    8    2
#> 18   32    2   18    0    0   18    1   10    0
#> 19   28    0   23    0    4   27    0   39    1

# Appearances for the 1984 Cleveland Indians
Appearances %>%
  filter(teamID == "CLE" & yearID == 1984)
#>    yearID teamID lgID  playerID G_all  GS G_batting G_defense G_p G_c G_1b G_2b
#> 1    1984    CLE   AL apontlu01    25   0         0        25  25   0    0    0
#> 2    1984    CLE   AL bandoch01    75  60        75        64   0  63    1    0
#> 3    1984    CLE   AL barklje01     3   0         0         3   3   0    0    0
#> 4    1984    CLE   AL behenri01     3   3         0         3   3   0    0    0
#> 5    1984    CLE   AL bernato01   140 122       140       136   0   0    0  136
#> 6    1984    CLE   AL blylebe01    33  32         0        33  33   0    0    0
#> 7    1984    CLE   AL butlebr01   159 149       159       156   0   0    0    0
#> 8    1984    CLE   AL camacer01    69   0         0        69  69   0    0    0
#> 9    1984    CLE   AL cartejo01    66  55        66        60   0   0    7    0
#> 10   1984    CLE   AL castica01    87  56        87        70   0   0    0    0
#> 11   1984    CLE   AL comerst01    22  20         0        22  22   0    0    0
#> 12   1984    CLE   AL easteja01    26   1         0        26  26   0    0    0
#> 13   1984    CLE   AL  farrst01    31  16         0        31  31   0    0    0
#> 14   1984    CLE   AL fischmi01    85  45        85        83   0   0    0   55
#> 15   1984    CLE   AL francju01   160 158       160       159   0   0    0    0
#> 16   1984    CLE   AL frazige01    22   0         0        22  22   0    0    0
#> 17   1984    CLE   AL  hallme01    83  65        83        69   0   0    0    0
#> 18   1984    CLE   AL hargrmi01   133  85       133       124   0   0  124    0
#> 19   1984    CLE   AL hassero01    48  39        48        45   0  44    1    0
#> 20   1984    CLE   AL heatone01    38  34         0        38  38   0    0    0
#> 21   1984    CLE   AL jacobbr01   126 125       126       126   0   0    0    0
#> 22   1984    CLE   AL jeffcmi01    63   1         0        63  63   0    0    0
#> 23   1984    CLE   AL moronje01     7   5         7         6   0   0    0    0
#> 24   1984    CLE   AL nixonot01    49  29        49        46   0   0    0    0
#> 25   1984    CLE   AL noboaju01    23   1        23        19   0   0    0   19
#> 26   1984    CLE   AL perkibr01    58   7        58         2   0   0    2    0
#> 27   1984    CLE   AL quirkja01     1   0         1         1   0   1    0    0
#> 28   1984    CLE   AL rhombke01    13   2        13         9   0   0    1    1
#> 29   1984    CLE   AL romanjo02     3   2         0         3   3   0    0    0
#> 30   1984    CLE   AL romerra01     1   0         0         1   1   0    0    0
#> 31   1984    CLE   AL schuldo01    19  14         0        19  19   0    0    0
#> 32   1984    CLE   AL smithro01    22  14         0        22  22   0    0    0
#> 33   1984    CLE   AL spillda01    14   8         0        14  14   0    0    0
#> 34   1984    CLE   AL sutclri01    15  15         0        15  15   0    0    0
#> 35   1984    CLE   AL tablepa01   144 131       144       139   0   0   67    1
#> 36   1984    CLE   AL thornan01   155 155       155        11   0   0   11    0
#> 37   1984    CLE   AL ujdurje01     4   3         0         4   4   0    0    0
#> 38   1984    CLE   AL vukovge01   134 110       134       130   0   0    0    0
#> 39   1984    CLE   AL waddeto01    58   0         0        58  58   0    0    0
#> 40   1984    CLE   AL willaje01    87  68        87        76   0  76    0    0
#>    G_3b G_ss G_lf G_cf G_rf G_of G_dh G_ph G_pr
#> 1     0    0    0    0    0    0    0    0    0
#> 2     1    0    0    0    0    0    1   13    0
#> 3     0    0    0    0    0    0    0    0    0
#> 4     0    0    0    0    0    0    0    0    0
#> 5     0    0    0    0    0    0    1    3    4
#> 6     0    0    0    0    0    0    0    0    0
#> 7     0    0    0  156    1  156    0    3    2
#> 8     0    0    0    0    0    0    0    0    0
#> 9     0    0   48   14    0   59    0    8    1
#> 10    0    0    0    0   70   70    2   26    1
#> 11    0    0    0    0    0    0    0    0    0
#> 12    0    0    0    0    0    0    0    0    0
#> 13    0    0    0    0    0    0    0    0    0
#> 14   17   15    0    0    0    0    0    2    7
#> 15    0  159    0    0    0    0    1    1    1
#> 16    0    0    0    0    0    0    0    0    0
#> 17    0    0   64    1    6   69    9   13    0
#> 18    0    0    0    0    0    0    0   20    0
#> 19    0    0    0    0    0    0    1    3    0
#> 20    0    0    0    0    0    0    0    0    0
#> 21  126    1    0    0    0    0    0    0    0
#> 22    0    0    0    0    0    0    0    0    0
#> 23    6    0    0    0    0    0    1    1    1
#> 24    0    0   43    4    0   46    0    0   10
#> 25    0    0    0    0    0    0    2    0    6
#> 26    0    0    0    0    0    0   10   50    1
#> 27    0    0    0    0    0    0    0    0    0
#> 28    0    0    7    0    0    7    1    3    4
#> 29    0    0    0    0    0    0    0    0    0
#> 30    0    0    0    0    0    0    0    0    0
#> 31    0    0    0    0    0    0    0    0    0
#> 32    0    0    0    0    0    0    0    0    0
#> 33    0    0    0    0    0    0    0    0    0
#> 34    0    0    0    0    0    0    0    0    0
#> 35   36    0   43    0    0   43    1    8    4
#> 36    0    0    0    0    0    0  144    0    0
#> 37    0    0    0    0    0    0    0    0    0
#> 38    0    0   16    0  124  130    0   15    0
#> 39    0    0    0    0    0    0    0    0    0
#> 40    0    0    0    0    0    0    1   12    0

# Pete Rose's primary position each year of his career
Appearances %>% 
   filter(playerID == "rosepe01") %>%
   group_by(yearID, teamID) %>%
   gather(pos, G, G_1b:G_rf) %>%
   filter(G == max(G)) %>%
   select(yearID:G_all, pos, G) %>%
   mutate(pos = substring(as.character(pos), 3, 4)) %>%
   arrange(yearID, teamID)
#> # A tibble: 25 × 7
#> # Groups:   yearID, teamID [25]
#>    yearID teamID lgID  playerID G_all pos       G
#>     <int> <fct>  <fct> <chr>    <int> <chr> <int>
#>  1   1963 CIN    NL    rosepe01   157 2b      157
#>  2   1964 CIN    NL    rosepe01   136 2b      128
#>  3   1965 CIN    NL    rosepe01   162 2b      161
#>  4   1966 CIN    NL    rosepe01   156 2b      140
#>  5   1967 CIN    NL    rosepe01   148 lf      124
#>  6   1968 CIN    NL    rosepe01   149 rf      142
#>  7   1969 CIN    NL    rosepe01   156 rf      101
#>  8   1970 CIN    NL    rosepe01   159 rf      155
#>  9   1971 CIN    NL    rosepe01   160 rf      156
#> 10   1972 CIN    NL    rosepe01   154 lf      154
#> # ℹ 15 more rows


# Most pitcher appearances each year since 1950
Appearances %>%
   filter(yearID >= 1950) %>%
   group_by(yearID) %>%
   summarise(maxPitcher = playerID[which.max(G_p)],
             maxAppear = max(G_p))
#> # A tibble: 74 × 3
#>    yearID maxPitcher maxAppear
#>     <int> <chr>          <int>
#>  1   1950 konstji01         74
#>  2   1951 kindeel01         63
#>  3   1952 wilheho01         71
#>  4   1953 kindeel01         69
#>  5   1954 hugheji02         60
#>  6   1955 labincl01         60
#>  7   1956 facero01          68
#>  8   1957 lowntu01          67
#>  9   1958 elstodo01         69
#> 10   1959 stalege01         67
#> # ℹ 64 more rows

# Individuals who have played all 162 games since 1961
all162 <- Appearances %>%
              filter(yearID > 1960 & G_all == 162) %>% 
              arrange(yearID, playerID) %>%
              select(yearID:G_all)
# Number of all-gamers by year (returns a vector)
table(all162$yearID)
#> 
#> 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1973 1974 1975 1976 1977 
#>    2    6    3    9    5    5    1    3    5    2    2    6    4    3    2    4 
#> 1978 1979 1980 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1996 
#>    4    8    7    8    4    5    4    5    2    2    5    2    3    4    2    3 
#> 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 
#>    6    4    5    5    7    6    5    3   10    6    7    4    1    2    1    3 
#> 2013 2014 2015 2016 2017 2018 2019 2021 2022 2023 
#>    4    4    1    3    5    6    5    2    2    4 

# Players with most pinch hitting appearances in a year
Appearances %>%
  arrange(desc(G_ph)) %>%
  select(playerID, yearID, teamID, lgID, G_all, G_ph) %>%
  head(., 10)
#>     playerID yearID teamID lgID G_all G_ph
#> 1  suzukic01   2017    MIA   NL   136  109
#> 2  harrile01   2001    NYN   NL   110   95
#> 3  staubru01   1983    NYN   NL   104   94
#> 4  sweenma01   2008    LAN   NL    98   94
#> 5  vandejo02   1995    COL   NL   105   92
#> 6  francma01   2003    ATL   NL   112   92
#> 7  nortogr01   2009    ATL   NL    95   91
#> 8  lasteto01   2018    CHN   NL   123   91
#> 9  perryge01   1993    SLN   NL    96   88
#> 10 francma01   1999    NYN   NL   122   88

# Players with most pinch hitting appearances, career
Appearances %>%
  group_by(playerID) %>%
  select(playerID, G_all, G_ph) %>%
  summarise(G = sum(G_all), PH = sum(G_ph)) %>%
  arrange(desc(PH)) %>%
  head(., 10)
#> # A tibble: 10 × 3
#>    playerID      G    PH
#>    <chr>     <int> <int>
#>  1 harrile01  1903   927
#>  2 sweenma01  1218   819
#>  3 hanseda01  1230   768
#>  4 grossgr01  1809   748
#>  5 vandejo02  1372   659
#>  6 burgesm01  1692   606
#>  7 motama01   1536   597
#>  8 palmeor01  1206   538
#>  9 dwyerji01  1328   524
#> 10 brownga01  1051   522

# Players with most career appearances at each position
Appearances %>%
  select(playerID, G_c:G_rf) %>%
  rename(C = G_c, `1B` = G_1b, `2B` = G_2b, SS = G_ss,
         `3B` = G_3b, LF = G_lf, CF = G_cf, RF = G_rf) %>%
  gather(pos, G, C:RF) %>%
  group_by(pos, playerID) %>%
  summarise(G = sum(G)) %>%
  arrange(desc(G)) %>%
  do(head(., 1))
#> `summarise()` has grouped output by 'pos'. You can override using the `.groups`
#> argument.
#> # A tibble: 8 × 3
#> # Groups:   pos [8]
#>   pos   playerID      G
#>   <chr> <chr>     <int>
#> 1 1B    murraed02  2413
#> 2 2B    collied01  2648
#> 3 3B    robinbr01  2870
#> 4 C     rodriiv01  2427
#> 5 CF    mayswi01   2829
#> 6 LF    bondsba01  2715
#> 7 RF    clemero01  2305
#> 8 SS    vizquom01  2709