longest_common_prefix: Find the longest common prefix between 2 random names. If no...

View source: R/general_utils.R

longest_common_prefixR Documentation

Find the longest common prefix between 2 random names. If no common prefix is found the same input values are returned.

Description

Find the longest common prefix between 2 random names. If no common prefix is found the same input values are returned.

Usage

longest_common_prefix(names, uniquify = TRUE, verbose = TRUE)

Arguments

names

A character vector with length higher than 1.

uniquify

Logical, should names become a unique vector before sampling 2 random names? Default FALSE, setting to TRUE, could help finding a better longest common prefix.

verbose

Logical, print common prefix found.

Value

A character vector without common prefix that is the same length as the input.

Examples

new_names <- longest_common_prefix(names)

Ni-Ar/niar documentation built on Feb. 3, 2025, 9:25 a.m.