View source: R/trimRedundText.R
trimRedundText | R Documentation |
This function allows trimming/removing redundant text-fragments (redundant from head or tail) out of character vector 'txt'.
trimRedundText(
txt,
minNchar = 1,
side = "both",
spaceElim = FALSE,
silent = TRUE,
callFrom = NULL,
debug = FALSE
)
txt |
character vector to be treated |
minNchar |
(integer) minumin number of characters that must remain |
side |
(character) may be be either 'both', 'left' or 'right' |
spaceElim |
(logical) optional removal of any heading or tailing white space |
silent |
(logical) suppress messages |
callFrom |
(character) allow easier tracking of messages produced |
debug |
(logical) display additional messages for debugging |
This function returns a modified character vector
Inverse : Find/keep common text keepCommonText
; checkUnitPrefix
;
you may also look for related functions in package stringr
txt1 <- c("abcd_ccc","bcd_ccc","cde_ccc")
trimRedundText(txt1, side="right") # trim from right
txt2 <- c("ddd_ab","ddd_bcd","ddd_cde")
trimRedundText(txt2, side="left") # trim from left
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.