Created
December 27, 2022 17:44
-
-
Save matt-dray/a43c2d85dce4d28d348afee22fb8593a to your computer and use it in GitHub Desktop.
Is Stiliyan Petrov the only Premier League player whose name contains the letters of the word 'nativity'?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# @optajoe on Twitter: | |
# Stiliyan Petrov is the only player to have played in the Premier | |
# League whose name contains all the letters in the word 'Nativity'. | |
# Here: https://twitter.com/OptaJoe/status/1607028528289030144 | |
# Is that true? I decided to find out using my {soccercolleagues} | |
# package for R: https://www.rostrum.blog/2022/02/04/soccercolleagues/ | |
install_github("matt-dray/soccercolleagues") | |
library(soccercolleagues) | |
library(tidyverse) | |
epl_players <- get_players( | |
seasons = 1992:2022, | |
country = "England" | |
) | |
epl_players |> | |
distinct(player_name) |> | |
mutate( | |
player_name = str_remove_all(tolower(player_name), " "), | |
n_count = str_count(player_name, "n"), | |
a_count = str_count(player_name, "a"), | |
t_count = str_count(player_name, "t"), | |
i_count = str_count(player_name, "i"), | |
v_count = str_count(player_name, "v"), | |
y_count = str_count(player_name, "y") | |
) |> | |
filter( | |
n_count >= 1 & | |
a_count >= 1 & | |
t_count >= 2 & | |
i_count >= 2 & | |
v_count >= 1 & | |
y_count >= 1 | |
) | |
# # A tibble: 1 × 7 | |
# player_name n_count a_count t_count i_count v_count y_count | |
# <chr> <int> <int> <int> <int> <int> <int> | |
# 1 stiliyanpetrov 1 1 2 2 1 1 | |
# Yes, it's true. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment