Learn R Programming

wrMisc (version 1.15.3.1)

trimRedundText: 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
)

Value

This function returns a modified character vector

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) allows easier tracking of messages produced

debug

(logical) display additional messages for debugging

See Also

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

Examples

Run this code
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 

Run the code above in your browser using DataLab