mlbstatsR es un package que tiene como objetivo facilitar las estadisticas, fotos de los jugadores, los logos y los colores de los equipos de la liga profesional de Baseball MLB, para visualizaciones y graficas
Ejemplo:
El package contiene las siguientes funciones:
get_mlb_teams()
get_mlb_players()
get_png_logos()
get_mlb_bateo()
get_mlb_pitcheo()
mlb_team_stats()
get_reference_players_mlb()
get_reference_team_mlb()
espn_player_stats()
espn_team_stats()
En CRAN
install.packages("mlbstatsR")
library(mlbstatsR)En GitHub
devtools::install_github("IvoVillanueva/mlbstatsR")
library(mlbstatsR)Nos devuelve los logos de los equipos en formato svg y sus colores, con diferentes columnas para facilitar su union con otras tablas. Util si solo necesitas esta info, recomendable darle un ajuste a la altura ya que el ancho es igual en todos pero la altura no, como hice en este caso
## name liga league division location mascot
## 1 Arizona Diamondbacks NL mlb NL West Arizona Diamondbacks
## 2 Atlanta Braves NL mlb NL East Atlanta Braves
## 3 Baltimore Orioles AL mlb AL East Baltimore Orioles
## 4 Boston Red Sox AL mlb AL East Boston Red Sox
## 5 Chicago Cubs NL mlb NL Central Chicago Cubs
## 6 Chicago White Sox AL mlb AL Central Chicago White Sox
## logo team primary
## 1 https://www.mlbstatic.com/team-logos/team-cap-on-light/109.svg ARI #A71930
## 2 https://www.mlbstatic.com/team-logos/team-cap-on-light/144.svg ATL #CE1141
## 3 https://www.mlbstatic.com/team-logos/team-cap-on-light/110.svg BAL #DF4601
## 4 https://www.mlbstatic.com/team-logos/team-cap-on-light/111.svg BOS #BD3039
## 5 https://www.mlbstatic.com/team-logos/team-cap-on-light/112.svg CHC #0E3386
## 6 https://www.mlbstatic.com/team-logos/team-cap-on-light/145.svg CHW #27251F
## secondary tertiary quaternary
## 1 #E3D4AD #000000 #30CED8
## 2 #13274F #EAAA00 #CE1141
## 3 #000000 #FC4C02 #27251F
## 4 #0C2340 <NA> <NA>
## 5 #CC3433 <NA> <NA>
## 6 #C4CED4 #002663 #CC092F
Lista de los jugadores con sus fotos y los logos de los equipos a los que pertenecen para no tener que cargar otra tabla. Los nombres están en el formato de ESPN con lo habrá que modificar algún acento o algun nombre para unirlo con las columnas de Baseball Reference, aunque eso se soluciona la mayoria de las veces con stringdist_left_joint de la library (fuzzyjoin), también recomiendo hacer un mutate (espn_nombres=str_squish(espn_nombres) para quitar los espacios en blanco del principio y al final que pudiera haber
## id_player espn_nombres
## 1 39948 John Means
## 2 31214 Matt Harvey
## 3 41118 Bruce Zimmermann
## 4 33833 Jorge Lopez
## 5 34950 Dillon Tate
## 6 33909 Paul Fry
## cabezas
## 1 https://a.espncdn.com/i/headshots/mlb/players/full/39948.png
## 2 https://a.espncdn.com/i/headshots/mlb/players/full/31214.png
## 3 https://a.espncdn.com/i/headshots/mlb/players/full/41118.png
## 4 https://a.espncdn.com/i/headshots/mlb/players/full/33833.png
## 5 https://a.espncdn.com/i/headshots/mlb/players/full/34950.png
## 6 https://a.espncdn.com/i/headshots/mlb/players/full/33909.png
## mlb_names liga league division location mascot
## 1 Baltimore Orioles AL mlb AL East Baltimore Orioles
## 2 Baltimore Orioles AL mlb AL East Baltimore Orioles
## 3 Baltimore Orioles AL mlb AL East Baltimore Orioles
## 4 Baltimore Orioles AL mlb AL East Baltimore Orioles
## 5 Baltimore Orioles AL mlb AL East Baltimore Orioles
## 6 Baltimore Orioles AL mlb AL East Baltimore Orioles
## logo team primary
## 1 https://www.mlbstatic.com/team-logos/team-cap-on-light/110.svg BAL #DF4601
## 2 https://www.mlbstatic.com/team-logos/team-cap-on-light/110.svg BAL #DF4601
## 3 https://www.mlbstatic.com/team-logos/team-cap-on-light/110.svg BAL #DF4601
## 4 https://www.mlbstatic.com/team-logos/team-cap-on-light/110.svg BAL #DF4601
## 5 https://www.mlbstatic.com/team-logos/team-cap-on-light/110.svg BAL #DF4601
## 6 https://www.mlbstatic.com/team-logos/team-cap-on-light/110.svg BAL #DF4601
## secondary tertiary quaternary
## 1 #000000 #FC4C02 #27251F
## 2 #000000 #FC4C02 #27251F
## 3 #000000 #FC4C02 #27251F
## 4 #000000 #FC4C02 #27251F
## 5 #000000 #FC4C02 #27251F
## 6 #000000 #FC4C02 #27251F
Otra tabla con logos, 4 , esta vez en PNG extraido de ESPN y dos columnas de colores primarios y secundarios
## 4 MLB ESPN logos in png!
## # A tibble: 30 x 13
## id slug location name abbreviation displayname short_display_n… primary
## <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 29 arizo… Arizona Diam… ARI Arizona Di… Diamondbacks #prima…
## 2 15 atlan… Atlanta Brav… ATL Atlanta Br… Braves #prima…
## 3 1 balti… Baltimo… Orio… BAL Baltimore … Orioles #prima…
## 4 2 bosto… Boston Red … BOS Boston Red… Red Sox #prima…
## 5 16 chica… Chicago Cubs CHC Chicago Cu… Cubs #prima…
## 6 4 chica… Chicago Whit… CHW Chicago Wh… White Sox #prima…
## 7 17 cinci… Cincinn… Reds CIN Cincinnati… Reds #prima…
## 8 5 cleve… Clevela… Indi… CLE Cleveland … Indians #prima…
## 9 27 color… Colorado Rock… COL Colorado R… Rockies #prima…
## 10 6 detro… Detroit Tige… DET Detroit Ti… Tigers #prima…
## # … with 20 more rows, and 5 more variables: secondary <chr>,
## # logo_default <chr>, logo_dark <chr>, logo_scoreboard <chr>,
## # logo_dark_scoreboard <chr>
He puesto un fondo oscuro para que se vean bien los blancos
Tabla que descarga la API de la pagina oficial de bateo de la MLB con 400 jugadores 68 columnas, tarda un tiempo en descargar, casi un minuto porque tiene paginación, es recomendable guardar en csv para no sobrecargar el servidor. Contiene datos desde 1903, entre parentesis ponemos el año que queremos descargar
Ejemplo: get_mlb_pitcheo(2018)
Lo mismo que la anterior pero de pitcheo
Ejemplo: get_mlb_bateo(2019)
Nos devuelve lo mismo que las dos anteriores pero resumido en una función y con la ventaja de poder elegir entre regular , playoffs, wildcard, divisionales, championship, mundiales o pretemporada
Ejemplo: mlb_player_full (1945, “hitting”, “regular”)
## Getting hitting stats de la regular season del 1945!
## # A tibble: 425 x 52
## season_type stat year player_id player_name rank player_full_name
## <chr> <chr> <chr> <int> <chr> <int> <chr>
## 1 Regular Season hitting 1945 121345 Bill Rodgers 1 Bill Rodgers
## 2 Regular Season hitting 1945 122691 Ray Starr 2 Ray Starr
## 3 Regular Season hitting 1945 118279 Phil Marchildon 3 Phil Marchildon
## 4 Regular Season hitting 1945 119081 Hack Miller 3 Hack Miller
## 5 Regular Season hitting 1945 121643 Jack Salveson 5 Jack Salveson
## 6 Regular Season hitting 1945 114351 Dick Fowler 6 Dick Fowler
## 7 Regular Season hitting 1945 112671 Claude Corbitt 7 Claude Corbitt
## 8 Regular Season hitting 1945 123554 Mike Ulisney 8 Mike Ulisney
## 9 Regular Season hitting 1945 110297 Luke Appling 9 Luke Appling
## 10 Regular Season hitting 1945 115782 Earl Henry 10 Earl Henry
## # … with 415 more rows, and 45 more variables: player_first_name <chr>,
## # player_last_name <chr>, player_use_name <chr>, player_init_last_name <chr>,
## # team_id <int>, team_abbrev <chr>, team_name <chr>, team_short_name <chr>,
## # league_name <chr>, league_id <int>, position_abbrev <chr>, position <chr>,
## # primary_position_abbrev <chr>, plate_appearances <int>, total_bases <int>,
## # sac_bunts <int>, babip <chr>, extra_base_hits <int>, hit_by_pitch <int>,
## # gidp <int>, walks_per_plate_appearance <chr>,
## # strikeouts_per_plate_appearance <chr>,
## # home_runs_per_plate_appearance <chr>, walks_per_strikeout <chr>, iso <chr>,
## # balls_in_play <int>, games_played <int>, runs <int>, doubles <int>,
## # triples <int>, home_runs <int>, strike_outs <int>, base_on_balls <int>,
## # hits <int>, avg <chr>, at_bats <int>, obp <chr>, slg <chr>, ops <chr>,
## # stolen_bases <int>, ground_into_double_play <int>, rbi <int>,
## # at_bats_per_home_run <chr>, caught_stealing <int>,
## # stolen_base_percentage <chr>
Descarga la información por equipo de la pagina oficial de la MLB Desde el año 1903, seleccionamos pitching o hitting y dentro de estos podemos seleccionar regular, playoffs, wildcard, divisionales, championship, mundiales o pretemporada. Como por ejemplo :
mlb_team_stats( 2018, “pitching”, “regular”)
Descarga de la página baseball-reference desde el año 1876 las estadsiticas de los jugadores en Batting Pitching y Fielding.
En Batting podemos seleccionar standard, advanced, value, probability, ratio, baserunning, pitchesbatting, neutralizedbatting, situational, baserunning, cumulative . Como por ejemplo :
get_reference_players_mlb(1945, “batting”, “value”)
## LOADING 1945 batting value from the index:
## 'advanced', 'value', 'probability', 'ratio', 'baserunning', 'standard'
## 'pitchesbatting', 'neutralizedbatting','situational', 'baserunning' o 'cumulative'
## # A tibble: 547 x 27
## year stats stats_type rk name age tm g pa rbat rbaser rdp
## <dbl> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 1945 batt… value 1 Ace … 35 NYG 65 20 -2 0 0
## 2 1945 batt… value 2 Bust… 30 2TM 154 707 15 0 1
## 3 1945 batt… value 3 Morr… 29 2TM 70 174 -1 -1 1
## 4 1945 batt… value 4 Nate… 31 BSN 22 53 -5 0 0
## 5 1945 batt… value 5 Stan… 28 2TM 34 89 -4 1 0
## 6 1945 batt… value 6 John… 29 2TM 127 540 -16 -2 -1
## 7 1945 batt… value 7 Pete… 41 2TM 8 5 0 0 0
## 8 1945 batt… value 8 Luke… 38 CHW 18 70 7 0 0
## 9 1945 batt… value 9 Joe … 22 PHA 10 18 -3 0 0
## 10 1945 batt… value 10 Jim … 28 CLE 25 61 -1 0 0
## # … with 537 more rows, and 15 more variables: rfield <chr>, rpos <chr>,
## # raa <chr>, waa <chr>, rrep <chr>, rar <chr>, war <chr>,
## # waa_wl_percent <chr>, x162wl_percent <chr>, o_war <chr>, d_war <chr>,
## # o_rar <chr>, salary <chr>, acquired <chr>, pos_summary <chr>
En Pitching podemos seleccionar advanced, value, probability, ratio, battingagainst, startingpitching, standard, reliefpitching, neutralizedpitching, baserunning o cumulative. Como por ejemplo :
get_reference_players_mlb(1965, “pitching”, “ratio”)
## LOADING 1965 pitching ratio from the index:
## 'advanced', 'value', 'probability', 'ratio', 'battingagainst', 'startingpitching',
## 'standard', 'reliefpitching', 'neutralizedpitching', 'baserunning' o 'cumulative'
## # A tibble: 341 x 25
## year stats stats_type rk name age tm ip ptn_percent hr_percent
## <dbl> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 1965 pitch… ratio 1 Ted A… 32 CHC 136.1 57% 1.2%
## 2 1965 pitch… ratio 2 Hank … 34 DET 208.1 19% 2.7%
## 3 1965 pitch… ratio 3 Jack … 24 KCA 51.1 59% 1.4%
## 4 1965 pitch… ratio 4 Matty… 26 SFG 2.0 30% 0.0%
## 5 1965 pitch… ratio 5 Don A… 22 HOU 6.0 35% 0.0%
## 6 1965 pitch… ratio 6 Gerry… 24 CIN 54.0 27% 1.5%
## 7 1965 pitch… ratio 7 Denni… 24 STL 7.1 58% 0.0%
## 8 1965 pitch… ratio 8 Jack … 28 PHI 99.0 61% 0.9%
## 9 1965 pitch… ratio 9 Steve… 27 BAL 220.2 20% 1.8%
## 10 1965 pitch… ratio 10 Ed Ba… 21 BAL 4.1 82% 0.0%
## # … with 331 more rows, and 15 more variables: so_percent <chr>,
## # bb_percent <chr>, so_bb_percent <chr>, xbh_percent <chr>,
## # x_h_percent <chr>, gb_fb <chr>, go_ao <chr>, ip_percent <chr>,
## # ld_percent <chr>, hr_fb <chr>, if_fb <chr>, opp <chr>, dp <chr>,
## # percent <chr>, p_au <chr>
En Fielding podemos seleccionar appearances, pitcher, catcher, firstbase, secondbase, thirdbase, shortstop, leftfield, centerfield, rightfield, outfield. Como por ejemplo :
get_reference_players_mlb(2002, “fielding”, “appearances”)
## LOADING 2002 fielding appearances from the index:
## 'appearances', 'pitcher', 'catcher', 'firstbase', 'secondbase', 'thirdbase',
## 'shortstop', 'leftfield', 'centerfield', 'rightfield', 'outfield'
## # A tibble: 1,218 x 25
## year stats stats_type rk name age tm yrs g gs batting
## <dbl> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 2002 field… appearances 1 Paul Ab… 34 SEA 9 7 5 0
## 2 2002 field… appearances 2 Brent A… 24 TBD 2 117 115 117
## 3 2002 field… appearances 3 Bobby A… 28 PHI 7 157 153 157
## 4 2002 field… appearances 4 Jose Ac… 24 CIN 2 6 5 6
## 5 2002 field… appearances 5 Juan Ac… 32 DET 7 65 0 4
## 6 2002 field… appearances 6 Terry A… 29 PHI 8 46 19 45
## 7 2002 field… appearances 7 Jeremy … 23 KCR 1st 34 7 0
## 8 2002 field… appearances 8 Benny A… 30 2TM 5 61 41 61
## 9 2002 field… appearances 9 Kurt Ai… 23 SFG 2 6 4 6
## 10 2002 field… appearances 10 Israel … 29 MIL 3 16 6 16
## # … with 1,208 more rows, and 14 more variables: defense <chr>, p <chr>,
## # c <chr>, x1b <chr>, x2b <chr>, x3b <chr>, ss <chr>, lf <chr>, cf <chr>,
## # rf <chr>, of <chr>, dh <chr>, ph <chr>, pr <chr>
Descarga de la página baseball-reference desde el año 1876 las estadisticas de los equipos en Batting Pitching y Fielding.
En Batting podemos seleccionar standard, advanced, value, probability, ratio, baserunning, pitchesbatting, neutralizedbatting, situational. Como por ejemplo :
get_reference_team_mlb(2021,“batting”, “advanced”)
## LOADING 2021 batting advanced from the index:
## 'advanced', 'value', 'probability', 'ratio', 'baserunning',
## 'standard', 'pitchesbatting', 'situational' o 'baserunning'
## # A tibble: 33 x 26
## year stats stats_type tm r_g outs rc rc_g air b_abip ba lg_ba
## <dbl> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 2021 batt… advanced ARI 4.73 1114 200 4.7 99 .285 .237 .245
## 2 2021 batt… advanced ATL 4.67 1057 191 4.8 106 .269 .229 .253
## 3 2021 batt… advanced BAL 3.85 1062 154 3.8 93 .279 .231 .238
## 4 2021 batt… advanced BOS 5.17 1099 212 5.1 96 .314 .264 .242
## 5 2021 batt… advanced CHC 4.54 1038 176 4.5 94 .289 .231 .238
## 6 2021 batt… advanced CHW 5.13 997 192 5.1 92 .325 .259 .237
## 7 2021 batt… advanced CIN 5.39 1035 195 5.0 107 .298 .252 .255
## 8 2021 batt… advanced CLE 4.03 1020 140 3.6 96 .243 .209 .242
## 9 2021 batt… advanced COL 4.85 1073 191 4.7 107 .304 .249 .255
## 10 2021 batt… advanced DET 3.48 1043 140 3.5 91 .295 .222 .236
## # … with 23 more rows, and 14 more variables: obp <chr>, lg_obp <chr>,
## # slg <chr>, lg_slg <chr>, ops <chr>, lg_ops <chr>, ops_2 <chr>,
## # o_wn_percent <chr>, bt_runs <chr>, bt_wins <chr>, tot_a <chr>, sec_a <chr>,
## # iso <chr>, pwr_spd <chr>
En Pitching podemos seleccionar standard, batting, value, probability, ratio, battingagainst, startingpitching, reliefpitching, basesituation. Como por ejemplo:
get_reference_team_mlb(1980, “pitching”, “battingagainst”)
## LOADING 1980 pitching battingagainst from the index:
## 'batting', 'value', 'probability', 'ratio', 'battingagainst', 'startingpitching',
## 'reliefpitching', 'basesituation', 'standard'
## # A tibble: 29 x 30
## year stats stats_type tm ra_g p_au g pa ab r h x2b
## <dbl> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 1980 pitch… batting ATL 4.10 "" 161 6028 5423 660 1397 232
## 2 1980 pitch… batting BAL 3.95 "" 162 6131 5510 640 1438 241
## 3 1980 pitch… batting BOS 4.79 "" 160 6192 5571 767 1557 287
## 4 1980 pitch… batting CAL 4.98 "" 160 6256 5563 797 1548 271
## 5 1980 pitch… batting CHC 4.49 "" 162 6402 5613 728 1525 263
## 6 1980 pitch… batting CHW 4.46 "" 162 6199 5448 722 1434 217
## 7 1980 pitch… batting CIN 4.11 "" 163 6143 5511 670 1404 246
## 8 1980 pitch… batting CLE 5.04 "" 160 6221 5531 807 1519 230
## 9 1980 pitch… batting DET 4.64 "" 163 6335 5630 757 1505 252
## 10 1980 pitch… batting HOU 3.61 "" 163 6160 5562 589 1367 203
## # … with 19 more rows, and 18 more variables: x3b <chr>, hr <chr>, sb <chr>,
## # cs <chr>, bb <chr>, so <chr>, ba <chr>, obp <chr>, slg <chr>, ops <chr>,
## # b_abip <chr>, tb <chr>, gdp <chr>, hbp <chr>, sh <chr>, sf <chr>,
## # ibb <chr>, roe <chr>
En Fielding podemos seleccionar standard, appearances, pitcher, catcher, firstbase, secondbase, thirdbase, shortstop, leftfield, centerfield, rightfield, outfield. Ejemplo:
get_reference_team_mlb(1980, “fielding”, “centerfield”)
## LOADING 1980 fielding centerfield from the index:
## 'appearances', 'pitcher', 'catcher', 'firstbase', 'secondbase', 'thirdbase',
## 'shortstop', 'leftfield', 'centerfield', 'rightfield', 'outfield'
## # A tibble: 29 x 20
## year stats stats_type tm number_fld ra_g g gs cg inn ch
## <dbl> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 1980 field… specialpos… ATL 5 4.10 161 161 150 1428… 412
## 2 1980 field… specialpos… BAL 2 3.95 162 162 154 1460… 524
## 3 1980 field… specialpos… BOS 7 4.79 160 160 146 1441… 457
## 4 1980 field… specialpos… CAL 4 4.98 160 160 134 1428… 504
## 5 1980 field… specialpos… CHC 6 4.49 162 162 129 1479… 424
## 6 1980 field… specialpos… CHW 5 4.46 162 162 149 1435… 450
## 7 1980 field… specialpos… CIN 6 4.11 163 163 74 1459… 474
## 8 1980 field… specialpos… CLE 6 5.04 160 160 143 1428… 466
## 9 1980 field… specialpos… DET 5 4.64 163 163 139 1467… 483
## 10 1980 field… specialpos… HOU 5 3.61 163 163 148 1482… 446
## # … with 19 more rows, and 9 more variables: po <chr>, a <chr>, e <chr>,
## # dp <chr>, fld_percent <chr>, rtot <chr>, rtot_yr <chr>, rtz <chr>,
## # rof <chr>
Descarga de la pagina de ESPN las estadisticas de los jugadores de la MLB desde el año 2002. Podemos seleccionar Regular o Playoffs y las estadisticas de batting, pitching y fielding.
espn_player_stats(2015, “pitching”, “regular”)
## Getting pitching stats de la regular season del 2015!
## # A tibble: 78 x 23
## year season_type rank name team pos games_played games_started
## <dbl> <chr> <int> <chr> <chr> <chr> <int> <int>
## 1 2015 regular 1 Zack Greinke LAD SP 32 32
## 2 2015 regular 2 Jake Arrieta CHC SP 33 33
## 3 2015 regular 3 Clayton Kersh… LAD SP 33 33
## 4 2015 regular 4 David Price DET SP 32 32
## 5 2015 regular 5 Dallas Keuchel HOU SP 33 33
## 6 2015 regular 6 Jacob deGrom NYM SP 30 30
## 7 2015 regular 7 Gerrit Cole PIT SP 32 32
## 8 2015 regular 8 Matt Harvey NYM SP 29 29
## 9 2015 regular 9 Sonny Gray OAK SP 31 31
## 10 2015 regular 10 John Lackey STL SP 33 33
## # … with 68 more rows, and 15 more variables: quality_starts <int>,
## # earned_run_avg <dbl>, wins <int>, losses <int>, saves <int>, holds <int>,
## # innings_pitched <dbl>, hits <int>, earned_runs <int>, home_runs <int>,
## # walks <int>, strikeouts <int>, strikes_x_9_i <dbl>, war <dbl>, whip <dbl>
espn_player_stats(2004, “batting”, “playoffs”)
## Getting batting stats de los playoffs del 2004!
## # A tibble: 61 x 23
## year season_type rank name team pos games_played at_bats runs hits
## <dbl> <chr> <int> <chr> <chr> <chr> <int> <int> <int> <int>
## 1 2004 playoffs 1 Andruw … ATL LF 5 19 4 10
## 2 2004 playoffs 2 Darin E… ANA LF 3 10 2 5
## 3 2004 playoffs 3 Michael… MIN LF 4 15 1 7
## 4 2004 playoffs 4 Carlos … HOU OF 12 46 21 20
## 5 2004 playoffs 5 Albert … STL 1B 15 58 15 24
## 6 2004 playoffs 6 Hideki … NYY LF 11 51 12 21
## 7 2004 playoffs 7 David O… BOS DH 14 55 13 22
## 8 2004 playoffs 8 Rafael … ATL 2B 5 21 5 8
## 9 2004 playoffs 9 Troy Gl… ANA 1B 3 11 3 4
## 10 2004 playoffs 10 Torii H… MIN RF 4 17 5 6
## # … with 51 more rows, and 13 more variables: batting_avg <dbl>, doubles <int>,
## # triples <int>, home_runs <int>, runs_batted_in <int>, total_bases <int>,
## # walks <int>, strikeouts <int>, stolen_bases <int>, on_base_pct <dbl>,
## # slugging_pct <dbl>, opb_slg_pct <dbl>, war <dbl>
Descarga de la pagina de ESPN las estadisticas de los equipos de la MLB desde el año 2002. Podemos seleccionar Regular o Playoffs y las estadisticas de batting, pitching y fielding.
espn_team_stats(2021, “fielding”, “regular”)
## Getting fielding stats de la regular season del 2021!
## # A tibble: 30 x 10
## year season_type rank team g_played errors fielding_percen… total_chances
## <dbl> <chr> <int> <chr> <int> <int> <dbl> <chr>
## 1 2021 regular 1 San F… 40 11 0.992 1,444
## 2 2021 regular 2 Houst… 41 14 0.99 1,447
## 3 2021 regular 3 Tampa… 42 17 0.989 1,498
## 4 2021 regular 4 Chica… 39 18 0.987 1,421
## 5 2021 regular 5 Atlan… 40 20 0.986 1,434
## 6 2021 regular 6 Toron… 39 20 0.986 1,396
## 7 2021 regular 7 Phila… 41 21 0.985 1,445
## 8 2021 regular 8 Washi… 36 18 0.985 1,235
## 9 2021 regular 9 Balti… 40 21 0.985 1,407
## 10 2021 regular 10 St. L… 41 22 0.985 1,436
## # … with 20 more rows, and 2 more variables: putouts <chr>, assists <int>
espn_team_stats(2011, “fielding”, “playoffs”)
## Getting fielding stats de los playoffs del 2011!
## # A tibble: 8 x 10
## year season_type rank team g_played errors fielding_percen… total_chances
## <dbl> <chr> <int> <chr> <int> <int> <dbl> <int>
## 1 2011 playoffs 1 Tampa … 4 0 0 143
## 2 2011 playoffs 2 New Yo… 5 1 0.995 194
## 3 2011 playoffs 3 Arizon… 5 1 0.994 164
## 4 2011 playoffs 4 Detroi… 11 5 0.988 401
## 5 2011 playoffs 5 St. Lo… 18 10 0.985 685
## 6 2011 playoffs 6 Philad… 5 3 0.984 190
## 7 2011 playoffs 7 Texas … 17 12 0.981 646
## 8 2011 playoffs 8 Milwau… 11 12 0.971 408
## # … with 2 more variables: putouts <int>, assists <int>
Espero que sea util