This function standardizes soccer team names to Fotmob defaults.
Arguments
- team_name
a character vector of team names
- keep_non_matches
If
TRUE
(the default) an element ofteam_name
that can't be matched to any of the internal mapping vectors will be kept as is. Otherwise it will be replaced withNA
.
Value
A character vector with the length of team_name
and cleaned team names
if they are included in team_name_mapping
, etc.
Non matches may be replaced with NA
(depending on the value of keep_non_matches
).
Examples
# \donttest{
team_names <- c('Bournemouth', 'AFC Bournemouth', 'Bournemouth AFC')
# keep non matches
soccerplotR::clean_team_names(team_names)
#> Bournemouth AFC Bournemouth <NA>
#> "Bournemouth" "Bournemouth" "Bournemouth AFC"
# drop "bad" names
soccerplotR::clean_team_names(team_names, keep_non_matches = FALSE)
#> Bournemouth AFC Bournemouth <NA>
#> "Bournemouth" "Bournemouth" NA
# silence warnings
# options(soccerplotR.verbose = FALSE)
soccerplotR::clean_team_names(team_names)
#> Bournemouth AFC Bournemouth <NA>
#> "Bournemouth" "Bournemouth" "Bournemouth AFC"
# }