Skip to content
Justice Tech School

Practice: Word Frequency

Split text and count with table.

Example
text <- "the cat and the hat and the bat"
w <- strsplit(text, " ")[[1]]
t <- sort(table(w), decreasing = TRUE)
print(t)
print(names(t)[1])

Exercise

Count words.

(w)

Quiz Test

What does strsplit return?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.