Learn R Programming

wrMisc (version 1.15.3.1)

treatTxtDuplicates: Locate duplicates in text and make non-redundant

Description

treatTxtDuplicates locates duplictes in character-vector 'x' and return list (length=3) : with $init (initial), $nRed .. non-redundant text by adding number at end or beginning, and $nrLst .. list-version with indexes per unique entry. Note : NAs (if multiple) will be renamed to NA_1, NA_2

Usage

treatTxtDuplicates(
  x,
  atEnd = TRUE,
  sep = "_",
  onlyCorrectToUnique = FALSE,
  silent = FALSE,
  debug = FALSE,
  callFrom = NULL
)

Value

list with $init, $nRed, $nrLst

Arguments

x

(character) vector with character-entries to identify (and remove) duplicates

atEnd

(logical) decide location of placing the counter (at end or at beginning of ID) (see correctToUnique)

sep

(character) separator to add before counter when making non-redundant version

onlyCorrectToUnique

(logical) if TRUE, return only vector of non-redundant

silent

(logical) suppress messages

debug

(logical) additional messages for debugging

callFrom

(character) allow easier tracking of messages produced

See Also

For simple correction use correctToUnique

Examples

Run this code
treatTxtDuplicates(c("li0",NA,rep(c("li2","li3"),2)))
correctToUnique(c("li0",NA,rep(c("li2","li3"),2)))

Run the code above in your browser using DataLab