word_frequency: Map terms from a corpus and compute its word frequency

View source: R/word_frequency.R

word_frequencyR Documentation

Map terms from a corpus and compute its word frequency

Description

[Experimental]

word_frequency() map terms from a vector using the tm package system and outputs a tibble summarizing word frequencies.

Please note that word_frequency() is required for other iramuteqlike functions.

Usage

word_frequency(
  x,
  language = "en",
  stopwords = language,
  other_stopwords = NULL
)

Arguments

x

An atomic vector (usually a character object) with a corpus (a collection of documents containing text). Each element of x will represent a document (e.g., a response from a survey).

language

(optional) a string indicating the corpus language. See tm::SimpleCorpus() to learn more (default: "en").

stopwords

(optional) a string indicating the corpus language to be pass to tm::stopwords(). tm::stopwords() return various kinds of words related to a specific language to help clean a text analysis (default: "en").

other_stopwords

(optional) a string indicating other stop words to be removed from the text analysis.

Value

A tibble object with two columns:

  • word: with an unique set of words mapped from x.

  • freq: with the absolute frequency of a word in word.

Examples

if (requireNamespace("friends", quietly = TRUE)) {
    word_frequency(head(friends::friends[[1]], 100))
}

if (requireNamespace("stringi", quietly = TRUE)) {
    word_frequency(stringi::stri_rand_lipsum(5))
}

gipso/iramuteqlike documentation built on July 7, 2024, 6:48 p.m.