R/join_fifa_ratings.R

Defines functions join_fifa_ratings

Documented in join_fifa_ratings

#' Join fifa ratings
#' @param data tibble obtained from `load_seasons`
#'
join_fifa_ratings <- function(data) {

  df_fifa_ratings <- get_fifa_team_ratings()

  data %>%
    dplyr::left_join(df_fifa_ratings %>% dplyr::rename_with(.cols = 2:5, ~paste0("Home", .x)), by = c("HomeTeam" = "Team")) %>%
    dplyr::left_join(df_fifa_ratings %>% dplyr::rename_with(.cols = 2:5, ~paste0("Away", .x)), by = c("AwayTeam" = "Team"))



}
kristian-bak/football documentation built on Oct. 8, 2022, 2:11 p.m.