longest_affix {hutils} | R Documentation |
Longest common prefix/suffix
Description
Longest common prefix/suffix
Usage
trim_common_affixes(
x,
.x = NULL,
na.rm = TRUE,
prefixes = TRUE,
suffixes = TRUE,
warn_if_no_prefix = TRUE,
warn_if_no_suffix = TRUE
)
longest_suffix(x, .x = NULL, na.rm = TRUE, warn_if_no_suffix = TRUE)
longest_prefix(x, .x = NULL, na.rm = TRUE, warn_if_no_prefix = TRUE)
Arguments
x |
A character vector. |
.x |
If |
na.rm |
(logical, default: If |
prefixes |
(logical, default: |
suffixes |
(logical, default: |
warn_if_no_prefix , warn_if_no_suffix |
(logical, default: |
Value
The longest common substring in x
either at the start or end of each string.
For trim_common_affixes
x
with common prefix and common suffix
removed.
Examples
longest_prefix(c("totalx", "totaly", "totalz"))
longest_suffix(c("ztotal", "ytotal", "xtotal"))
[Package hutils version 1.8.1 Index]