R/source_objects.R

# Note, experimental w/ source_scrapes.R. Do not use yet.

# Creating player_table object so it is no longer sent to the
# global environemnt upon loading
player_table = NULL


# CBS ----
cbs_columns = c(
  "Player" = "player",
  "Team" = "team",
  "Pass Attempts" = "pass_att",
  "Pass Completions" = "pass_comp",
  "Passing Yards" = "pass_yds",
  "Touchdowns Passes" = "pass_tds",
  "Interceptions Thrown" = "pass_int",
  "Passing CmpPct" = "pass_comp_pct",
  "Passing YAtt" = "pass_avg",
  "Rushing Attempts" = "rush_att",
  "Rushing Yards" = "rush_yds",
  "Average Yards Per Rush" = "rush_avg",
  "Rushing Touchdowns" = "rush_tds",
  "Receptions" = "rec",
  "Targets" = "rec_tgt",
  "Passer Rating" = "pass_rate",
  "Passing Yards Per Game" = "pass_yds_g",
  "Yards Per Game" = "rec_yds_g",
  "Games Played" = "games",
  "Receiving Yards" = "rec_yds",
  "Average Yards Per Reception" = "rec_avg",
  "Receiving Touchdowns" = "rec_tds",
  "Fumbles Lost" = "fumbles_lost",
  "Field Goals Made" = "fg",
  "Field Goal Attempts" = "fg_att",
  "Longest Field Goal" = "fg_long",
  "Field Goals 1-19 Yards" = "fg_0019",
  "Field Goals 20-29 Yards" = "fg_2029",
  "Field Goals 30-39 Yards" = "fg_3039",
  "Field Goals 40-49 Yards" = "fg_4049",
  "Field Goals 50+ Yards" = "fg_50",
  "Field Goals 1-19 Yard Attempts" = "fg_att_0019",
  "Field Goals 20-29 Yard Attempts" = "fg_att_2029",
  "Field Goals 30-39 Yard Attempts" = "fg_att_3039",
  "Field Goals 40-49 Yard Attempts" = "fg_att_4049",
  "Field Goals 50+ Yards Attempts" = "fg_att_50",
  "Extra Points Made" = "xp",
  "Extra Points Attempted" = "xp_att",
  "Interceptions" = "dst_int",
  "Tackles" = "dst_tackles",
  "Defensive Fumbles Recovered" = "dst_fum_rec",
  "Forced Fumbles" = "dst_fum_force",
  "Sacks" = "dst_sacks",
  "Defensive Touchdowns" = "dst_td",
  "Safeties" = "dst_safety",
  "Points Allowed" = "dst_pts_allowed",
  "Total Yards Allowed" = "dst_yds_allowed",
  "Points Allowed Per Game" = "dst_pts_allowed_g",
  "Rushing Yards Allowed" = "dst_rush_yds_allowed",
  "Net Passing Yards Allowed" = "dst_pass_yds_allowed",
  "Yards Against Per Game" = "dst_avg_yds_allowed",
  "Fantasy Points" = "site_pts",
  "Fantasy Points Per Game" = "site_fppg"
  )

# NFL ----
nfl_columns = c(
  "Player" = "player",
  "id" = "src_id",
  "name" = "player",
  "teamabbr" = "team",
  "Team" = "team",
  "position" = "pos",
  "Opp" = "opp",
  "Passing Yds" = "pass_yds",
  "Rushing Yds" = "rush_yds",
  "Passing TD" = "pass_tds",
  "Passing Int" = "pass_int",
  "Rushing TD" = "rush_tds",
  "Fum Lost" = "fumbles_lost",
  "Misc 2PT" = "two_pts",
  "Misc FumTD" = "fumble_TD",
  "GP" = "games",
  "Receiving Rec" = "rec",
  "Receiving Yds" = "rec_yds",
  "Receiving TD" = "rec_tds",
  "Ret TD" = "return_tds",
  "Tack" = "idp_solo",
  "Ast" = "idp_asst",
  "PAT Made" = "xp",
  "FG Made 0-19" = "fg_0019",
  "FG Made 20-29" = "fg_2029",
  "FG Made 30-39" = "fg_3039",
  "FG Made 40-49" = "fg_4049",
  "FG Made 50+" = "fg_50",
  "Tackles Sack" = "dst_sacks",
  "Turnover Int" = "dst_int",
  "Turnover Fum Rec" = "dst_fum_rec",
  "Score TD" = "dst_td",
  "Pts Allow" = "dst_pts_allowed",
  "Ret TD" = "return_tds",
  "Score Saf" = "dst_safety",
  "Score Def 2pt Ret" = "dst_2pt_ret",
  "Block" = "dst_blk" ,
  "Sack" = "idp_sack",
  "Frc Fum" = "idp_fum_force",
  "Pass Def" = "idp_pd",
  "Blk" = "idp_blk",
  "Fum Rec" = "idp_fum_rec",
  "Int" = "idp_int",
  "Saf" = "idp_safety",
  "Points Pts Allow" = "dst_pts_allowed",
  "Fantasy Points" = "site_pts",
  "seasonProjectedPts" = "site_season_pts",
  "weekProjectedPts" = "site_pts"
)
nfl_pos_idx = c("QB" = 1, "RB" = 2, "WR" = 3, "TE" = 4, "K" = 7, "DST" = 8)

# RT Sports ----

# Misc
rts_pos_idx = c("QB" = 0, "RB" = 1, "WR" = 2, "TE" = 3, "K" = 4, "DST" = 5)

# RTS Sports columns
rts_columns = c(
  "player_id" = "src_id",
  "name" = "player",
  "nfl_team" = "team",
  "pass_atts" = "pass_att",
  "pass_comps" = "pass_comp",
  "pass_ints" = "pass_int",
  "rush_atts" = "rush_att",
  "pts_ppr" = "site_pts",
  "rec_rcpts" = "rec",
  "kick_patm" = "xp",
  "kick_fgm" = "fg",
  "kick_fga" = "fg_att",
  "pts_allowed" = "dst_pts_allowed",
  "yds_allowed" = "dst_yds_allowed",
  "sacks" = "dst_sacks",
  "ints" = "dst_int",
  "fumbles_recovered" = "dst_fum_rec"
  )

# Fantasy sharks ----

fantasysharks_columns = c(
  `Player ID` = "id",
  `Player Name` = "player",
  Position = "pos",
  Team = "team",
  Att = "pass_att",
  Comp = "pass_comp",
  `Pass Yds` = "pass_yds",
  `Pass TDs` = "pass_tds",
  `0-9 PassTDs` = "pass_09_tds",
  `10-19 PassTDs` = "pass_1019_tds",
  `20-29 PassTDs` = "pass_2029_tds",
  `30-39 PassTDs` = "pass_3039_tds",
  `40-49 PassTDs` = "pass_4049_tds",
  `50+ PassTDs` = "pass_50_tds",
  Int = "pass_int",
  Sacked = "sacks",
  `>= 250yds` = "pass_250_yds",
  `>= 300yds` = "pass_300_yds",
  `>= 350yds` = "pass_350_yds",
  Rush = "rush_att",
  `Rush Yds` = "rush_yds",
  `Rush TDs` = "rush_tds",
  `Fum Lost` = "fumbles_lost",
  `Scoring Opps` = "scoring_opp",
  `Opp` = "opp",
  `0-9 RushTDs` = "rush_09_tds",
  `10-19 RushTDs` = "rush_1019_tds",
  `20-29 RushTDs` = "rush_2029_tds",
  `30-39 RushTDs` = "rush_3039_tds",
  `40-49 RushTDs` = "rush_4049_tds",
  `50+ RushTDs` = "rush_50_tds",
  `>= 50yds` = "rush_50_yds",
  `>= 100yds` = "rush_100_yds",
  Tgt = "rec_tgt",
  `RZTgt` = "rec_rz_tgt",
  Rec = "rec",
  `Rec Yds` = "rec_yds",
  `Rec TDs` = "rec_tds",
  `>= 50yds` = "rec_50_yds",
  `>= 100yds` = "rec_100_yds",
  `>= 150yds` = "rec_150_yds",
  `>= 200yds` = "rec_200_yds",
  `0-9 RecTDs` = "rec_09_tds",
  `10-19 RecTDs` = "rec_1019_tds",
  `20-29 RecTDs` = "rec_2029_tds",
  `30-39 RecTDs` = "rec_3039_tds",
  `40-49 RecTDs` = "rec_4049_tds",
  `50+ RecTDs` = "rec_50_tds",
  `Punt Ret Yds` = "return_yds",
  `Kick Ret Yds` = "return_yds",
  XP = "xp",
  XPA = "xp_att",
  FG = "fg",
  Att = "fg_att",
  `10-19` = "fg_0019",
  `20-29` = "fg_2029",
  `30-39` = "fg_3039",
  `40-49` = "fg_4049",
  `50+` = "fg_50",
  Miss = "fg_miss",
  `Yds Allowed` = "dst_yds_allowed",
  `100-199` = "dst_yds_199",
  `200-299` = "dst_yds_299",
  `300-349` = "dst_yds_349",
  `350-399` = "dst_yds_399",
  `400-449` = "dst_yds_449",
  `450-499` = "dst_yds_499",
  `500-549` = "dst_yds_549",
  `550+` = "dst_yds_550",
  `Pts Agn` = "dst_pts_allowed",
  `1-6` = "dst_pts_6",
  `7-13` = "dst_pts_13",
  `14-17` = "dst_pts_17",
  `18-20` = "dst_pts_20",
  `21-27` = "dst_pts_27",
  `28-34` = "dst_pts_34",
  `35-45` = "dst_pts_45",
  `46+` = "dst_pts_46",
  Scks = "dst_sacks",
  dst_int = "dst_int",
  Fum = "dst_fum_rec",
  DefTD = "dst_td",
  Safts = "dst_safety",
  Tack = "idp_solo",
  Asst = "idp_asst",
  idp_sack = "idp_sack",
  PassDef = "idp_pd",
  idp_int = "idp_int",
  FumFrc = "idp_fum_force",
  Fum = "idp_fum_rec",
  DefTD = "idp_td",
  Pts = "site_pts"
)

# Numberfire columns ----
numberfire_idp_columns = c(
  id = "id",
  numfire_id = "src_id",
  Player = "player",
  position = "pos",
  team = "team",
  data_src = "data_src",
  `Defense Tackles` = "idp_solo",
  `Defense Sacks` = "idp_sack",
  `Defense INTs` = "idp_int",
  `Defense TDs` = "idp_td",
  `Defense Passes Defended` = "idp_pd",
  `Defense Fum Rec` = "idp_fum_rec",
  `Fandual FP` = "fandual_site_points",
  `FanDuel Salary` = "fanduel_salary",
  `FanDuel Value` = "fanduel_value",
  `DraftKings FP` = "draftkings_site_points",
  `DraftKings Salary` = "draftkings_salary",
  `DraftKings Value` = "draftkings_value",
  `Yahoo FP` = "yahoo_site_points",
  `Yahoo Salary` = "yahoo_salary",
  `Yahoo Value` = "yahoo_value",
  `Opp Team` = "opp",
  `Opp Rank` = "opp_rank"
  )

numberfire_columns = c(
  id = "id",
  numfire_id = "src_id",
  Player = "player",
  position = "pos",
  `numberFire FP` = "site_pts",
  Lower = "site_ci_low",
  Upper = "site_ci_high",
  `Ranks Ovr.` = "ranks_ovr",
  `Ranks Pos.` = "ranks_pos",
  `Passing Yds` = "pass_yds",
  `Passing TDs` = "pass_tds",
  `Passing Ints` = "pass_int",
  `Rushing Att` = "rush_att",
  `Rushing Yds` = "rush_yds",
  `Rushing TDs` = "rush_tds",
  `Receiving Rec` = "rec",
  `Receiving Yds` = "rec_yds",
  `Receiving TDs` = "rec_tds",
  `Receiving Tgt` = "rec_tgt",
  `Kicking XPM` = "xp",
  `Kicking FGA` = "fg_att",
  `Kicking FGM` = "fg",
  `FG Made By Distance 0-19` = "fg_0019",
  `FG Made By Distance 20-29` = "fg_2029",
  `FG Made By Distance 30-39` = "fg_3039",
  `FG Made By Distance 40-49` = "fg_4049",
  `FG Made By Distance 50+` = "fg_50",
  `Defense Points Allowed` = "dst_pts_allowed",
  `Defense Yards Allowed` = "dst_yds_allowed",
  `Defense Sacks` = "dst_sacks",
  `Defense INTs` = "dst_int",
  `Defense Fumbles` = "dst_fum_rec",
  `Defense TDs` = "dst_td",
  `Opp Team` = "opp",
  `Opp Rank` = "opp_rank",
  `Fandual FP` = "fandual_site_points",
  `FanDuel Salary` = "fanduel_salary",
  `FanDuel Value` = "fanduel_value",
  `DraftKings FP` = "draftkings_site_points",
  `DraftKings Salary` = "draftkings_salary",
  `DraftKings Value` = "draftkings_value",
  `Yahoo FP` = "yahoo_site_points",
  `Yahoo Salary` = "yahoo_salary",
  `Yahoo Value` = "yahoo_value"
  )

# Walterfootball columns ----
walterfootball_columns = c(
  Player = "player",
  Team = "team",
  Bye = "bye",
  position = "pos",
  data_src = "data_src",
  `PASS YDS` = "pass_yds",
  `PASS TD` = "pass_tds",
  INT = "pass_int",
  `RUSH YDS` = "rush_yds",
  CATCH = "rec",
  `REC YDS` = "rec_yds",
  `REG TD` = "reg_tds",
  `FG 1-39` = "fg_0039",
  `FG 40-49` = "fg_4049",
  `FG 50+` = "fg_50",
  XP = "xp",
  `Points (ESPN Scoring)` = "site_pts"
  )

# FFToday columns ----
fftoday_columns = c(
  "Passing Comp" = "pass_comp",
  "Passing Att" = "pass_att",
  "Passing Yard" = "pass_yds",
  "Passing TD" = "pass_tds",
  "Passing INT" = "pass_int",
  "Rushing Att" = "rush_att",
  "Rushing Yard"  = "rush_yds",
  "Rushing TD" = "rush_tds",
  "Receiving Rec" = "rec",
  "Receiving Yard" = "rec_yds",
  "Receiving TD" = "rec_tds",
  "FGM" = "fg",
  "FGA" = "fg_att",
  "FG%" = "fg_pct",
  "EPM" = "xp",
  "EPA" = "xp_att",
  "FG Made" = "fg",
  "FG Miss" = "fg_miss",
  "XP Made" = "xp",
  "XP Miss" = "xp_miss",
  "Sack" = "dst_sacks",
  "FR" = "dst_fum_rec",
  "INT" = "dst_int",
  "DefTD" = "dst_td",
  "PA" = "dst_pts_allowed",
  "PaYd/G" = "dst_pass_yds_g",
  "RuYd/G" = "dst_rush_yds_g",
  "Safety" = "dst_safety",
  "KickTD" = "dst_ret_tds",
  "Tackle" = "idp_solo",
  "Assist" = "idp_asst",
  "Sack" = "idp_sack",
  "PD" = "idp_pd",
  "INT" = "idp_int",
  "FF" = "idp_fum_force",
  "FR" = "idp_fum_rec",
  "Fantasy FFPts" = "site_pts",
  "Fantasy FPts" = "site_pts",
  "Player" = "player",
  "Team" = "team",
  "Opp" = "opp",
  "Chg" = "chg",
  "Bye" = "bye"
  )

# Fantasypros columns ----
fantasypros_columns = c(
  "PASSING ATT" = "pass_att",
  "PASSING CMP" = "pass_comp",
  "PASSING YDS" = "pass_yds",
  "PASSING TDS" = "pass_tds",
  "PASSING INTS" = "pass_int",
  "RUSHING ATT" = "rush_att",
  "RUSHING YDS" = "rush_yds",
  "RUSHING TDS" = "rush_tds",
  "RECEIVING REC" = "rec",
  "RECEIVING YDS" = "rec_yds",
  "RECEIVING TDS" = "rec_tds",
  "FGA" = "fg_att",
  "XPT" = "xp",
  "MISC FL" = "fumbles_lost",
  "SACK" = "dst_sacks",
  "INT" = "dst_int",
  "FR" = "dst_fum_rec",
  "FF" = "dst_fum_force",
  "TD" = "dst_td",
  "SAFETY" = "dst_safety",
  "PA" = "dst_pts_allowed",
  "YDS AGN" = "dst_yds_allowed",
  "FPTS" = "site_pts",
  "MISC FPTS" = "site_pts",
  "Player" = "player",
  "FG" = "fg"
  )

# Fleaflicker columns ----

fleaflicker_columns = c(
  "Player Name" = "player",
  "Opp" = "opp",
  "FPts" = "curr_site_pts",
  "Rank Draft" = "draft_rank",
  "Rank PPR" = "ppr_rank",
  "Passing %" = "pass_comp_pct",
  "Passing Cmp" = "pass_comp",
  "Passing Att" = "pass_att",
  "Passing"= "pass_comp_pct",
  "Passing Yd" = "pass_yds",
  "Passing TD" = "pass_tds",
  "Passing INT" = "pass_int",
  "Passing Rat" = "pass_rate",
  "Rushing Att" = "rush_att",
  "Rushing Yd" = "rush_yds",
  "Rushing TD" = "rush_tds",
  "Receiving Rec" = "rec",
  "Receiving Tar" = "rec_tgt",
  "Receiving Yd" = "rec_yds",
  "Receiving TD" = "rec_tds",
  "Misc Fum" = "fumbles_lost",
  "Misc TD" = "misc_tds",
  "Misc Yd" = "misc_yds",
  "Kicking FG" = "fg",
  "fg_att" = "fg_att",
  "fg_pct" = "fg_pct",
  "Kicking XP" = "xp",
  "xp_att" = "xp_att",
  "xp_pct" = "xp_pct",
  "Defense INT" = "dst_int",
  "Defense Sack" = "dst_sacks",
  "Defense FF" = "dst_fum_force",
  "Defense FR" = "dst_fum_rec",
  "Defense TD" = "dst_td",
  "Defense Pts" = "dst_pts_allowed",
  "Defense Yd" = "dst_yds_allowed",
  "Team Defense Pts" = "dst_pts_allowed",
  "Team Defense Yd" = "dst_yds_allowed",
  "Defense Ast" = "idp_asst",
  "Defense Solo" = "idp_solo",
  "Defense INT" = "idp_int",
  "Defense Sack" = "idp_sack",
  "Defense FF" = "idp_fum_force",
  "Defense FR" = "idp_fum_rec",
  "Defense TD" = "idp_td",
  "Fantasy FPts" = "site_pts",
  "Availability % Own" = "pct_owned"
)


# NFL FastR calc player stats ----
nflfastr_calc_cols = c(
  "player_id" = "nflfastr_id",
  "recent_team" = "team",
  "completions" = "pass_comp",
  "attempts" = "pass_att",
  "passing_yards" = "pass_yds",
  "passing_tds" = "pass_tds",
  "interceptions" = "pass_int",
  "sack_fumbles",
  "sack_fumbles_lost",
  "passing_air_yards",
  "passing_yards_after_catch",
  "passing_first_downs",
  "passing_epa",
  "passing_2pt_conversions",
  "pacr",
  "dakota",
  "carries" = "rush_att",
  "rushing_yards" = "rush_yds",
  "rushing_tds" = "rush_tds",
  "rushing_fumbles",
  "rushing_fumbles_lost",
  "rushing_first_downs",
  "rushing_epa",
  "rushing_2pt_conversions",
  "receptions" = "rec",
  "targets" = "rec_tgt",
  "receiving_yards" = "rec_yds",
  "receiving_tds" = "rec_tds",
  "receiving_fumbles",
  "receiving_fumbles_lost",
  "receiving_air_yards",
  "receiving_yards_after_catch",
  "receiving_first_downs",
  "receiving_epa",
  "receiving_2pt_conversions",
  "racr",
  "target_share",
  "air_yards_share",
  "wopr",
  "special_teams_tds",
  "fantasy_points",
  "fantasy_points_ppr"
)

# ESPN ----

espn_columns = c(
  "0" = "pass_att",
  "1" = "pass_comp",
  "3" = "pass_yds",
  "4" = "pass_tds",
  "20" = "pass_int",
  "23" = "rush_att",
  "24" = "rush_yds",
  "25" = "rush_tds",
  "53" = "rec",
  "42" = "rec_yds",
  "43" = "rec_tds",
  "58" = "rec_tgt",
  "80" = "fg_39",
  "81" = "fg_att_39",
  "77" = "fg_49",
  "78" = "fg_49_att",
  "74" = "fg_50",
  "75" = "fg_50_att",
  "83" = "fg",
  "84" = "fg_att",
  "86" = "xp",
  "87" = "xp_att",
  "109" = "dst_tackles",
  "99" = "dst_sacks",
  "106" = "dst_fumbles",
  "96" = "dst_fum_recvr",
  "95" = "dst_int",
  "122" = "dst_td",
  "137" = "dst_pts_against",
  "127" = "dst_yds_against"
)

espn_team_nums = c(
  "0" = "FA", "1" = "ATL", "2" = "BUF", "3" = "CHI",  "4" = "CIN", "5" = "CLE",
  "6" = "DAL", "7" = "DEN", "8" = "DET", "9" = "GB", "10" = "TEN", "11" = "IND",
  "12" = "KCC", "13" = "LV", "14" = "LAR", "15" = "MIA", "16" = "MIN", "17" = "NE",
  "18" = "NO", "19" = "NYG", "20" = "NYJ",  "21" = "PHI", "22" = "ARI",
  "23" = "PIT", "24" = "LAC", "25" = "SF", "26" = "SEA", "27" = "TB", "28" = "WAS",
  "29" = "CAR", "30" = "JAC", "33" = "BAL", "34" = "HOU"
)
FantasyFootballAnalytics/ffanalytics documentation built on April 6, 2024, 6:56 p.m.