Learn R Programming

volker (version 2.1.0)

get_prefix: Get the common prefix of character values

Description

Helper function taken from the biobase package. Duplicated here instead of loading the package to avoid overhead. See https://github.com/Bioconductor/Biobase

Usage

get_prefix(x, ignore.case = FALSE, trim = FALSE, delimiters = c(":", "\n"))

Value

The longest common prefix of the strings.

Arguments

x

Character vector.

ignore.case

Whether case matters (default).

trim

Whether non alphabetic characters should be trimmed.

delimiters

A list of prefix delimiters. If any of the delimiters is present in the extracted prefix, the part after is removed from the prefix. Consider the following two items as an example: c("Usage: in private context", "Usage: in work context"). The common prefix would be

"Usage: in "

, but it makes more sense to break it after the colon.