library(tidyverse)
library(rvest)
url <- "http://www.allcompetitions.com/nfl_sbros.php"
res <- read_html(url) |>
html_element("table:nth-of-type(2)") |>
html_table() |>
set_names("teams")
res$teams |>
str_remove(".*?: ") |>
str_remove(". \\(.*") |>
str_split(", ") |>
unlist() |>
as_tibble() |>
set_names("player") |>
count(player, sort = TRUE) |>
count(n) |>
print() |>
count(n >= 2, wt = nn, sort = TRUE) |>
mutate(prop = n / sum(n))
#> Storing counts in `nn`, as `n` already present in input
#> ℹ Use `name = "new_name"` to pick a new name.
#> # A tibble: 6 × 2
#> n nn
#> <int> <int>
#> 1 1 1438
#> 2 2 358
#> 3 3 91
#> 4 4 28
#> 5 5 1
#> 6 7 2
#> # A tibble: 2 × 3
#> `n >= 2` n prop
#> <lgl> <int> <dbl>
#> 1 FALSE 1438 0.750
#> 2 TRUE 480 0.250
Created on 2023-10-11 with reprex v2.0.2