flag_words: Flag rows in a text.table with specific words

Description Usage Arguments Value Examples

View source: R/text.table.R

Description

Flag rows in a text.table with specific words

Usage

1
flag_words(x, text, flag = "flag", words)

Arguments

x

A text.table created by as.text.table().

text

A string, the name of the column in x to check for words to flag.

flag

A string, the name of the column created with the flag indicator.

words

A vector of words to flag x.

Value

A text.table, with rows marked with a 1 if the words in those rows are in the vector of words to delete, otherwise 0.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
flag_words(
as.text.table(
  x = as.data.table(
    list(
      col1 = c(
        "a",
        "b"
      ),
      col2 = c(
        tolower("The dog is nice because it picked up the newspaper."),
        tolower("The dog is extremely nice because it does the dishes.")
      )
    )
  ),
  text = "col2",
  split = " "
),
text = "col2",
flag = "is_stopword",
words = stopwords
)

textTools documentation built on Feb. 5, 2021, 5:07 p.m.