is.within_n_preceding_words: Check if Element Is Within N Preceding Words

Description Usage Arguments Value Examples

Description

Logical check of each element in a vector to determine if an element occurs within n preceding words.

Usage

1
is.within_n_preceding_words(x, regex.term, n = 0)

Arguments

x

A vector of elements.

regex.term

A regular expression that represents a word or term.

n

A max number of words (defined as ([a-zA-Z-]+,*\s+)) that regex.term must occur before.

Value

Returns a logical vector equal in length to x.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
x <- c(
    "I like dogs and cats",
    "I do not like robots though",
    "Like I care."
)

is.within_n_preceding_words(x, "I", 0)
is.within_n_preceding_words(x, "I", 1)
is.within_n_preceding_words(x, "like", 4)
is.within_n_preceding_words(x, "[Ll]ike", 4)

trinker/discon documentation built on May 31, 2019, 8:42 p.m.