FantasyFootballAnalytics / ffanalytics

ffanalytics R package
http://ffanalytics.fantasyfootballanalytics.net/
163 stars 100 forks source link

Missing MFL IDs (name-cleaning issue?) #153

Open TheMathNinja opened 2 months ago

TheMathNinja commented 2 months ago

Hi, I'm running this code because I want to work on joins by MFL ID using this package:

#Create df of all ffanalytics source site names
ffa_full_scrape <- ffanalytics::scrape_data(
  src = c("CBS", "ESPN", "FantasyPros", "FantasySharks", "FFToday", "NumberFire",
          "FantasyFootballNerd", "NFL", "RTSports", "Walterfootball"),
  pos = c("QB", "RB", "WR", "TE", "K", "DST", "DL", "LB", "DB"),
  season = 2024,
  week = 0
)

#Convert to readable dataframes by position
#WARNING: do not run the following df conversions unless the above scrape ran error-free (otherwise it will make empty df's)
ffaQB_scrape <- as.data.frame(ffa_full_scrape[1]) %>%
  rename_all(~stringr::str_replace(.,"^QB.",""))
ffaRB_scrape <- as.data.frame(ffa_full_scrape[2]) %>%
  rename_all(~stringr::str_replace(.,"^RB.",""))
ffaWR_scrape <- as.data.frame(ffa_full_scrape[3]) %>%
  rename_all(~stringr::str_replace(.,"^WR.",""))
ffaTE_scrape <- as.data.frame(ffa_full_scrape[4]) %>%
  rename_all(~stringr::str_replace(.,"^TE.",""))
ffaPK_scrape <- as.data.frame(ffa_full_scrape[5]) %>%
  rename_all(~stringr::str_replace(.,"^K.",""))
ffaDST_scrape <- as.data.frame(ffa_full_scrape[6]) %>%
  rename_all(~stringr::str_replace(.,"^DST.",""))
ffaDL_scrape <- as.data.frame(ffa_full_scrape[7]) %>%
  rename_all(~stringr::str_replace(.,"^DL.",""))
ffaLB_scrape <- as.data.frame(ffa_full_scrape[8]) %>%
  rename_all(~stringr::str_replace(.,"^LB.",""))
ffaDB_scrape <- as.data.frame(ffa_full_scrape[9]) %>%
  rename_all(~stringr::str_replace(.,"^DB.",""))

ffa_names_database <- bind_rows(ffaQB_scrape,
                                ffaRB_scrape,
                                ffaWR_scrape,
                                ffaTE_scrape,
                                ffaPK_scrape,
                                ffaDST_scrape,
                                ffaDL_scrape,
                                ffaLB_scrape,
                                ffaDB_scrape) %>%
  rename(mfl_id = id) %>%
  filter(is.na(mfl_id))

This shows curious omissions (like Chig Okonkwo and Josh Palmer missing MFL ID's at times). I'm guessing in the Okonkwo/Palmer case it's a name-cleaning issue where they aren't joining somewhere because of alternates to their name?