common_stem: Return the stem that is common to a set of strings

View source: R/string_tools.R

common_stemR Documentation

Return the stem that is common to a set of strings

Description

Return the stem that is common to a set of strings

Usage

common_stem(..., side = "left", na.rm = FALSE)

Arguments

...

(Vectors) Vectors that will be coerced into Character and appended together.

side

(Character) Search from the left or right side of the strings. Also accepts l or r as shorthand.

na.rm

(Logical) Should NA be removed from the input vectors?

Value

A string. If there is no common stem among all the words, an empty string of length 1 ("") will be returned.

Authors

Examples

vec <- c("exciting", "exceeding", "excepting")

common_stem(vec)
#> [1] "exc"

common_stem(vec, side = "r")
#> [1] "ing"

# The function does not return substrings:
common_stem("tableaux", "wobbles")
#> ""


DesiQuintans/desiderata documentation built on April 9, 2023, 5:43 a.m.