count_words | R Documentation |
x
.count_words
provides frequency counts of the
words in a string of text x
as a named numeric vector.
count_words(x, case_sense = TRUE, sort_freq = TRUE)
x |
A string of text (required). |
case_sense |
Boolean: Distinguish lower- vs. uppercase characters?
Default: |
sort_freq |
Boolean: Sort output by word frequency?
Default: |
Special (or non-word) characters are removed and not counted.
The quantification is case-sensitive and the resulting vector is sorted by name (alphabetically) or by frequency (per default).
A named numeric vector.
count_chars
for counting the frequency of characters;
count_chars_words
for counting both characters and words;
plot_chars
for a character plotting function.
Other text objects and functions:
Umlaut
,
capitalize()
,
caseflip()
,
cclass
,
chars_to_text()
,
collapse_chars()
,
count_chars_words()
,
count_chars()
,
invert_rules()
,
l33t_rul35
,
map_text_chars()
,
map_text_coord()
,
map_text_regex()
,
metachar
,
read_ascii()
,
text_to_chars()
,
text_to_sentences()
,
text_to_words()
,
transl33t()
,
words_to_text()
# Default:
s3 <- c("A first sentence.", "The second sentence.",
"A third --- and also THE FINAL --- SENTENCE.")
count_words(s3) # case-sensitive, sorts by frequency
# Options:
count_words(s3, case_sense = FALSE) # case insensitive
count_words(s3, sort_freq = FALSE) # sorts alphabetically
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.