CharacterCounts

CharacterCounts["string"]

gives an association whose keys are the distinct characters in string, and whose values give the number of times those characters appear in string.

CharacterCounts["string",n]

gives counts of the distinct n-grams consisting of runs of n characters in string.

Details and Options

Examples

open allclose all

Basic Examples  (3)

Count the distinct characters in a string:

Character counts include all characters, including numbers, punctuation, and whitespace:

Count the distinct 2-gram sequences in a string:

Scope  (1)

Find the characters of a biomolecular sequence:

Options  (1)

IgnoreCase  (1)

Count n-grams regardless of case:

Neat Examples  (1)

Find the most frequently occurring characters in the Gettysburg Address:

Do the same for 3-character sequences:

Wolfram Research (2015), CharacterCounts, Wolfram Language function, https://reference.wolfram.com/language/ref/CharacterCounts.html.

Text

Wolfram Research (2015), CharacterCounts, Wolfram Language function, https://reference.wolfram.com/language/ref/CharacterCounts.html.

CMS

Wolfram Language. 2015. "CharacterCounts." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/CharacterCounts.html.

APA

Wolfram Language. (2015). CharacterCounts. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/CharacterCounts.html

BibTeX

@misc{reference.wolfram_2023_charactercounts, author="Wolfram Research", title="{CharacterCounts}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/CharacterCounts.html}", note=[Accessed: 20-April-2024 ]}

BibLaTeX

@online{reference.wolfram_2023_charactercounts, organization={Wolfram Research}, title={CharacterCounts}, year={2015}, url={https://reference.wolfram.com/language/ref/CharacterCounts.html}, note=[Accessed: 20-April-2024 ]}