count_chars {ds4psy} | R Documentation |
Count the frequency of characters in a string of text x
.
Description
count_chars
provides frequency counts of the
characters in a string of text x
as a named numeric vector.
Usage
count_chars(x, case_sense = TRUE, rm_specials = TRUE, sort_freq = TRUE)
Arguments
x |
A string of text (required). |
case_sense |
Boolean: Distinguish lower- vs. uppercase characters?
Default: |
rm_specials |
Boolean: Remove special characters?
Default: |
sort_freq |
Boolean: Sort output by character frequency?
Default: |
Details
If rm_specials = TRUE
(as per default),
most special (or non-word) characters are
removed and not counted. (Note that this currently works
without using regular expressions.)
The quantification is case-sensitive and the resulting vector is sorted by name (alphabetically) or by frequency (per default).
Value
A named numeric vector.
See Also
count_words
for counting the frequency of words;
count_chars_words
for counting both characters and words;
plot_chars
for a corresponding plotting function.
Other text objects and functions:
Umlaut
,
capitalize()
,
caseflip()
,
cclass
,
chars_to_text()
,
collapse_chars()
,
count_chars_words()
,
count_words()
,
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()
Examples
# Default:
x <- c("Hello world!", "This is a 1st sentence.",
"This is the 2nd sentence.", "THE END.")
count_chars(x)
# Options:
count_chars(x, case_sense = FALSE)
count_chars(x, rm_specials = FALSE)
count_chars(x, sort_freq = FALSE)