This function returns the last n words of a string (by default, five). This can, for example, be helpful for extracting words from the left context columnumn of a concordance data frame.

last_left(x, column, n = 5, omit_punctuation = TRUE)

Arguments

x

A vector or data frame.

column

If x is a data frame, the number or name of the column.

n

number of words to return. Default is 5.

omit_punctuation

If TRUE (the default), strings consisting exclusively of non-alphanumeric characters will be omitted.

Value

A vector containing the last n words of each vector element.