trimRedundText {wrMisc}R Documentation

Trim redundant text

Description

This function allows trimming/removing redundant text-fragments (redundant from head or tail) out of character vector 'txt'.

Usage

trimRedundText(
  txt,
  minNchar = 1,
  side = "both",
  spaceElim = FALSE,
  silent = TRUE,
  callFrom = NULL,
  debug = FALSE
)

Arguments

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

Value

This function returns a modified character vector

See Also

Inverse : Find/keep common text keepCommonText; checkUnitPrefix; you may also look for related functions in package stringr

Examples

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 

[Package wrMisc version 1.15.1 Index]