library(mlbstatsR)
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
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()
get_reference_team_standings()
espn_player_stats()
espn_team_stats()
mlb_player_full()
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: 865 × 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 Jame… 26 KCM 2 6 1 0 0
#> 2 1945 batt… value 2 Ace … 35 NYG 65 20 -2 0 0
#> 3 1945 batt… value 3 Bust… 30 2TM 154 707 15 0 1
#> 4 1945 batt… value 4 Emer… 34 NBY 19 56 0 0 0
#> 5 1945 batt… value 5 Morr… 29 2TM 70 174 -1 -1 1
#> 6 1945 batt… value 6 Bill… 32 NYC 8 10 -2 0 0
#> 7 1945 batt… value 7 Nate… 31 BSN 22 53 -5 0 0
#> 8 1945 batt… value 8 Stan… 28 2TM 34 89 -4 1 0
#> 9 1945 batt… value 9 John… 29 2TM 127 540 -16 -2 -1
#> 10 1945 batt… value 10 Pete… 41 2TM 8 5 0 0 0
#> # … with 855 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 × 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 pitching ratio 1 Ted … 32 CHC 136.1 57% 1.2%
#> 2 1965 pitching ratio 2 Hank… 34 DET 208.1 19% 2.7%
#> 3 1965 pitching ratio 3 Jack… 24 KCA 51.1 59% 1.4%
#> 4 1965 pitching ratio 4 Matt… 26 SFG 2.0 30% 0.0%
#> 5 1965 pitching ratio 5 Don … 22 HOU 6.0 35% 0.0%
#> 6 1965 pitching ratio 6 Gerr… 24 CIN 54.0 27% 1.5%
#> 7 1965 pitching ratio 7 Denn… 24 STL 7.1 58% 0.0%
#> 8 1965 pitching ratio 8 Jack… 28 PHI 99.0 61% 0.9%
#> 9 1965 pitching ratio 9 Stev… 27 BAL 220.2 20% 1.8%
#> 10 1965 pitching ratio 10 Ed B… 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 × 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 fielding appearances 1 Paul … 34 SEA 9 7 5 0
#> 2 2002 fielding appearances 2 Brent… 24 TBD 2 117 115 117
#> 3 2002 fielding appearances 3 Bobby… 28 PHI 7 157 153 157
#> 4 2002 fielding appearances 4 Jose … 24 CIN 2 6 5 6
#> 5 2002 fielding appearances 5 Juan … 32 DET 7 65 0 4
#> 6 2002 fielding appearances 6 Terry… 29 PHI 8 46 19 45
#> 7 2002 fielding appearances 7 Jerem… 23 KCR 1st 34 7 0
#> 8 2002 fielding appearances 8 Benny… 30 2TM 5 61 41 61
#> 9 2002 fielding appearances 9 Kurt … 23 SFG 2 6 4 6
#> 10 2002 fielding appearances 10 Israe… 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: 34 × 26
#> year stats stats_type x batting batting_2 batting_3 batting_4
#> <dbl> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 2021 batting advanced Tm rOBA Rbat+ BAbip ISO
#> 2 2021 batting advanced Arizona Diamo… .309 86 .294 .146
#> 3 2021 batting advanced Atlanta Braves .331 94 .283 .192
#> 4 2021 batting advanced Baltimore Ori… .311 89 .288 .167
#> 5 2021 batting advanced Boston Red Sox .334 102 .309 .185
#> 6 2021 batting advanced Chicago Cubs .315 89 .289 .170
#> 7 2021 batting advanced Chicago White… .334 109 .307 .166
#> 8 2021 batting advanced Cincinnati Re… .332 90 .296 .180
#> 9 2021 batting advanced Cleveland Ind… .313 91 .278 .169
#> 10 2021 batting advanced Colorado Rock… .323 82 .295 .167
#> # … with 24 more rows, and 18 more variables: batting_ratios <chr>,
#> # batting_ratios_2 <chr>, batting_ratios_3 <chr>, batted_ball <chr>,
#> # batted_ball_2 <chr>, batted_ball_3 <chr>, batted_ball_4 <chr>,
#> # batted_ball_5 <chr>, batted_ball_6 <chr>, batted_ball_7 <chr>,
#> # batted_ball_8 <chr>, batted_ball_9 <chr>, win_probability <chr>,
#> # win_probability_2 <chr>, win_probability_3 <chr>, baserunning <chr>,
#> # baserunning_2 <chr>, baserunning_3 <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 × 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 Atla… 4.10 "" 161 6028 5423 660 1397 232
#> 2 1980 pitch… batting Balt… 3.95 "" 162 6131 5510 640 1438 241
#> 3 1980 pitch… batting Bost… 4.79 "" 160 6192 5571 767 1557 287
#> 4 1980 pitch… batting Cali… 4.98 "" 160 6256 5563 797 1548 271
#> 5 1980 pitch… batting Chic… 4.49 "" 162 6402 5613 728 1525 263
#> 6 1980 pitch… batting Chic… 4.46 "" 162 6199 5448 722 1434 217
#> 7 1980 pitch… batting Cinc… 4.11 "" 163 6143 5511 670 1404 246
#> 8 1980 pitch… batting Clev… 5.04 "" 160 6221 5531 807 1519 230
#> 9 1980 pitch… batting Detr… 4.64 "" 163 6335 5630 757 1505 252
#> 10 1980 pitch… batting Hous… 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 × 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… specialpo… Atlan… 5 4.10 161 161 150 1428… 412
#> 2 1980 field… specialpo… Balti… 2 3.95 162 162 154 1460… 524
#> 3 1980 field… specialpo… Bosto… 7 4.79 160 160 146 1441… 457
#> 4 1980 field… specialpo… Calif… 4 4.98 160 160 134 1428… 504
#> 5 1980 field… specialpo… Chica… 6 4.49 162 162 129 1479… 424
#> 6 1980 field… specialpo… Chica… 5 4.46 162 162 149 1435… 450
#> 7 1980 field… specialpo… Cinci… 6 4.11 163 163 74 1459… 474
#> 8 1980 field… specialpo… Cleve… 6 5.04 160 160 143 1428… 466
#> 9 1980 field… specialpo… Detro… 5 4.64 163 163 139 1467… 483
#> 10 1980 field… specialpo… Houst… 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>
Nos devuelve la clasificación de todas las maneras posibles y proyecciones de victorias
#> # A tibble: 31 × 25
#> year rk tm w l w_l_percent r ra rdiff sos srs
#> <dbl> <int> <chr> <int> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1999 1 Atlanta Br… 103 59 0.636 5.2 4.1 1.1 0.1 1.2
#> 2 1999 2 Arizona Di… 100 62 0.617 5.6 4.2 1.4 0.1 1.5
#> 3 1999 3 New York Y… 98 64 0.605 5.6 4.5 1 -0.3 0.8
#> 4 1999 4 Houston As… 97 65 0.599 5.1 4.2 0.9 0.1 1
#> 5 1999 5 Cleveland … 97 65 0.599 6.2 5.3 0.9 -0.3 0.6
#> 6 1999 6 New York M… 97 66 0.595 5.2 4.4 0.9 0.2 1
#> 7 1999 7 Cincinnati… 96 67 0.589 5.3 4.4 0.9 0.1 1.1
#> 8 1999 8 Texas Rang… 95 67 0.586 5.8 5.3 0.5 -0.2 0.3
#> 9 1999 9 Boston Red… 94 68 0.58 5.2 4.4 0.7 -0.2 0.5
#> 10 1999 10 Oakland At… 87 75 0.537 5.5 5.2 0.3 -0.2 0.1
#> # … with 21 more rows, and 14 more variables: pyth_wl <chr>, luck <int>,
#> # v_east <chr>, v_cent <chr>, v_west <chr>, inter <chr>, home <chr>,
#> # road <chr>, ex_inn <chr>, x1run <chr>, v_rhp <chr>, v_lhp <chr>,
#> # x500 <chr>, x500_2 <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 × 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 Kershaw 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 × 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 × 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 Houst… 142 59 0.988 5,084
#> 2 2021 regular 2 Oakla… 143 58 0.988 4,794
#> 3 2021 regular 3 Color… 144 65 0.987 5,094
#> 4 2021 regular 4 Balti… 143 55 0.987 4,296
#> 5 2021 regular 5 Pitts… 143 55 0.987 4,126
#> 6 2021 regular 6 Atlan… 142 62 0.986 4,573
#> 7 2021 regular 7 San F… 143 70 0.986 5,121
#> 8 2021 regular 8 Chica… 144 69 0.986 4,956
#> 9 2021 regular 9 Seatt… 143 71 0.986 5,060
#> 10 2021 regular 10 San D… 142 72 0.986 5,095
#> # … with 20 more rows, and 2 more variables: putouts <chr>, assists <chr>
espn_team_stats(2011, “fielding”, “playoffs”)
#> Getting fielding stats de los playoffs del 2011!
#> # A tibble: 8 × 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 1 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