Learn R Programming

contentanalysis (version 0.2.1)

calculate_readability_indices: Calculate readability indices for text

Description

Calculates multiple readability indices including Flesch-Kincaid Grade Level, Flesch Reading Ease, Automated Readability Index (ARI), and Gunning Fog Index.

Usage

calculate_readability_indices(text, detailed = FALSE)

Value

A tibble with the following columns:

  • flesch_kincaid_grade: US grade level required to understand the text

  • flesch_reading_ease: Score from 0-100 (higher = easier to read)

  • automated_readability_index: ARI grade level

  • gunning_fog_index: Grade level based on sentence length and complex words

If detailed = TRUE, also includes:

  • n_sentences: Number of sentences

  • n_words: Number of words

  • n_syllables: Total syllables

  • n_characters: Total characters

  • n_complex_words: Words with 3+ syllables

  • avg_sentence_length: Average words per sentence

  • avg_syllables_per_word: Average syllables per word

  • pct_complex_words: Percentage of complex words

Arguments

text

Character vector containing the text to analyze

detailed

Logical, if TRUE returns detailed statistics along with indices

Details

Formulas:

Flesch-Kincaid Grade Level: $$0.39 \times \frac{words}{sentences} + 11.8 \times \frac{syllables}{words} - 15.59$$

Flesch Reading Ease: $$206.835 - 1.015 \times \frac{words}{sentences} - 84.6 \times \frac{syllables}{words}$$

Automated Readability Index (ARI): $$4.71 \times \frac{characters}{words} + 0.5 \times \frac{words}{sentences} - 21.43$$

Gunning Fog Index: $$0.4 \times (\frac{words}{sentences} + 100 \times \frac{complex\_words}{words})$$

where complex words are those with 3 or more syllables.

Examples

Run this code
if (FALSE) {
# Simple text
text <- "The cat sat on the mat. It was a sunny day."
readability <- calculate_readability_indices(text)

# With detailed statistics
text2 <- "Reading is fun. Books open new worlds. They teach us many things."
readability_detailed <- calculate_readability_indices(text2, detailed = TRUE)
}

Run the code above in your browser using DataLab