Scrape Team Fielder Leaderboards from FanGraphs
Usage
fg_team_fielder(
age = "",
pos = "all",
stats = "fld",
lg = "all",
qual = "0",
startseason = "2023",
endseason = "2023",
startdate = "",
enddate = "",
month = "0",
hand = "",
team = "0,ts",
pageitems = "1000",
pagenum = "1",
ind = "0",
rost = "0",
players = "",
type = "1",
postseason = "",
sortdir = "default",
sortstat = "Defense"
)
Arguments
- age
(integer) Age of players
- pos
(character) Position of players, defaults to "all". To exclude pitchers, use "np".
- stats
(character) Statistic to return. Defaults to "bat".
- lg
(character) League to return. Defaults to "all". Options are "al", "nl", or "all".
- qual
(character) Whether you want only batters/pitchers that qualified in a given season, or the minimum number of plate appearances for inclusion. If you only want qualified hitters, use qual. If a minimum number of plate appearaces/innings pitched, use the number desired. Defaults to "y".
- startseason
(character) Season for which you want to scrape the data.
- endseason
(character) Last season for which you want data.
- startdate
(character) Start date for which you want data.
- enddate
(character) End date for which you want data.
- month
(character) Month for which you want data.
- hand
(character) Handedness of batter. Options are "L", "R", or "B". Empty string returns all.
- team
(character) Teams for which you want data, comma separated.
- pageitems
(character) Number of items per page.
- pagenum
(character) Page number.
- ind
(character) Whether or not to break the seasons out individual, or roll them up together. 1 = split seasons, 0 = aggregate seasons.
- rost
(character) Whether or not to include players on the roster. 1 = include, 0 = exclude.
- players
(character) Whether or not to include players on the roster. 1 = include only active roster players, 0 = exclude.
- type
(character) Defaults to 8, which is the standard leaderboard. The values for the leaderboards appear to go to from type = 0 to 48+, which correspond to links on the leaderboard page.
- postseason
(logical) Whether or not to include postseason data. TRUE = include postseason, FALSE = exclude postseason.
- sortdir
(character) Sort direction. Options are "asc" or "desc" or "default".
- sortstat
(character) Sort by stat. Default is "Defense".
Value
A data frame of fielder data.
col_name | types |
Season | integer |
team_name | character |
SeasonMin | integer |
SeasonMax | integer |
Pos | character |
G | integer |
GS | integer |
Inn | integer |
PO | integer |
A | integer |
E | integer |
FE | integer |
TE | integer |
DP | integer |
DPS | integer |
DPT | integer |
DPF | integer |
Scp | integer |
SB | integer |
CS | integer |
PB | integer |
WP | integer |
FP | numeric |
rSB | integer |
rGDP | integer |
rARM | integer |
rGFP | integer |
rPM | integer |
rSZ | numeric |
rTS | integer |
rCERA | integer |
DRS | integer |
BIZ | integer |
Plays | integer |
RZR | numeric |
OOZ | integer |
ARM | numeric |
DPR | numeric |
RngR | numeric |
ErrR | numeric |
UZR | numeric |
UZR_150 | numeric |
Defense | numeric |
CStrikes | numeric |
CFraming | numeric |
OAA | integer |
rFRP | integer |
Q | numeric |
TInn | numeric |
teamid | integer |
team_name_abb | character |
Examples
# \donttest{
try(fg_team_fielder(startseason = 2023, endseason = 2023, qual = 150))
#> ── MLB Team Fielding data from FanGraphs.com ──────── baseballr 1.6.0 ──
#> ℹ Data updated: 2024-04-13 21:55:10 UTC
#> # A tibble: 30 × 56
#> Season team_name SeasonMin SeasonMax Pos G GS Inn PO
#> <int> <chr> <int> <int> <chr> <int> <int> <int> <int>
#> 1 2023 Brewers 2023 2023 P 2225 1458 12987 4329
#> 2 2023 Diamondbacks 2023 2023 P 2235 1458 12918 4306
#> 3 2023 Royals 2023 2023 2B 2210 1458 12681 4227
#> 4 2023 Padres 2023 2023 P 2128 1458 12969 4323
#> 5 2023 Rangers 2023 2023 P 2121 1458 12927 4309
#> 6 2023 Mariners 2023 2023 LF 2166 1458 13044 4348
#> 7 2023 Astros 2023 2023 LF 2108 1458 13008 4336
#> 8 2023 Rockies 2023 2023 SS 2156 1458 12726 4242
#> 9 2023 Cubs 2023 2023 P 2142 1458 12918 4306
#> 10 2023 Blue Jays 2023 2023 P 2231 1458 13065 4355
#> # ℹ 20 more rows
#> # ℹ 47 more variables: A <int>, E <int>, FE <int>, TE <int>, DP <int>,
#> # DPS <int>, DPT <int>, DPF <int>, Scp <int>, SB <int>, CS <int>,
#> # PB <int>, WP <int>, FP <dbl>, rSB <int>, rGDP <int>, rARM <int>,
#> # rGFP <int>, rPM <int>, rSZ <dbl>, rTS <int>, rCERA <int>,
#> # DRS <int>, BIZ <int>, Plays <int>, RZR <dbl>, OOZ <int>, ARM <dbl>,
#> # DPR <dbl>, RngR <dbl>, ErrR <dbl>, UZR <dbl>, UZR_150 <dbl>, …
# }