filter_text: Replace word prefixes that occur in given words.

Description Usage Arguments Value Examples

View source: R/filter_text.R

Description

Finds words starting with a word in a given list, and replaces each such word prefix with a given replacement.

Usage

1
filter_text(.data, .filters, .replacement, ...)

Arguments

.data

A data.frame or tibble.

.filters

A list of words and/or regexes.

.replacement

A character string used as replacement.

...

Columns to act upon.

Value

The original data, filtered.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
data <- data.frame(
  x = c("This is some text...", "...containing words."),
  y = c("This is more text...", "...containing something."),
  z = c("This is some more text...", "...containing  more words.")
)

data <- data %>%
  filter_text(
    c("some", "words"),
    "#",
    x, y
  )

#                      x                        y                         z
# 1 This is #### text... This is more text...     This is some more text...
# 2 ...containing #####.  ...containing ####thing. ...containing more words.

MarkMc1089/profanityfilter documentation built on Feb. 5, 2022, 8:12 a.m.