RosettaCodeData/Task/Word-frequency/R/word-frequency-2.r
2023-07-01 13:44:08 -04:00

13 lines
304 B
R

word_frequency_pipeline <- function(file=NULL, n=10) {
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()
}