txt_previous: Get the n-th previous element of a vector

View source: R/utils.R

txt_previousR Documentation

Get the n-th previous element of a vector

Description

Get the n-th previous element of a vector

Usage

txt_previous(x, n = 1)

Arguments

x

a character vector where each element is just 1 term or word

n

an integer indicating how far to look back. Defaults to 1.

Value

a character vector of the same length of x with the previous element

See Also

shift

Examples

x <- sprintf("%s%s", LETTERS, 1:26)
txt_previous(x, n = 1)

data.frame(word = x,
           word_previous1 = txt_previous(x, n = 1),
           word_previous2 = txt_previous(x, n = 2),
           stringsAsFactors = FALSE)

udpipe documentation built on Jan. 6, 2023, 5:06 p.m.