Skip to contents

Remove all stop-words and specific patterns from a character vector

Usage

remove_stopwords(text, stop_words, exclude = NULL, sep = " ")

Arguments

text

Character vector

stop_words

Character vector. Words to exclude from text. Example: if you want to exclude "a", whenever that word appears it will be excluded, but when the letter "a" appears in a word, it will remain.

exclude

Character. Pattern to exclude using regex.

sep

Character. String that separate the terms.

Value

Character vector with removed texts.

See also

Examples

x <- c("A brown fox jumps over a dog.", "Another brown dog.")
remove_stopwords(x, stop_words = c("dog", "brown", "a"), exclude = "\\.")
#> [1] "fox jumps over" "Another"