2023-07-01 11:58:00 -04:00
|
|
|
word_frequency_pipeline <- function(file=NULL, n=10) {
|
2026-04-30 12:34:36 -04:00
|
|
|
|
2023-07-01 11:58:00 -04:00
|
|
|
file |>
|
|
|
|
|
vroom::vroom_lines() |>
|
|
|
|
|
stringi::stri_split_boundaries(type="word", skip_word_none=T, skip_word_number=T) |>
|
|
|
|
|
unlist() |>
|
|
|
|
|
tolower() |>
|
|
|
|
|
table() |>
|
|
|
|
|
sort(decreasing = T) |>
|
|
|
|
|
(\(.) .[1:n])() |>
|
|
|
|
|
data.frame()
|
2026-04-30 12:34:36 -04:00
|
|
|
|
2023-07-01 11:58:00 -04:00
|
|
|
}
|