nonAmbiguousNum {wrMisc}R Documentation

make numeric vector non-ambiguous (ie unique)

Description

nonAmbiguousNum makes (named) values of numeric vector 'x' unique. Note: for non-numeric use firstOfRepeated - but 1000x slower ! Return sorted non-ambigous numeric vector (or list if 'asList'=TRUE and 'uniqOnly'=FASLSE)

Usage

nonAmbiguousNum(
  x,
  uniqOnly = FALSE,
  asList = FALSE,
  nameMod = "amb_",
  callFrom = NULL
)

Arguments

x

(numeric) main input

uniqOnly

(logical) if=TRUE return unique only, if =FALSE return unique and single representative of non-unique values (with ” added to name), selection of representative of repeated: first (of sorted) or middle if >2 instances

asList

(logical) return list

nameMod

(character) text to add in case on ambiguous values, default="amb_"

callFrom

(character) allow easier tracking of message(s) produced

Value

sorted non-ambigous numeric vector (or list if 'asList'=TRUE and 'uniqOnly'=FALSE)

See Also

firstOfRepeated for non-numeric use (much slower !!!), duplicated

Examples

set.seed(2017); aa <- round(rnorm(100),2); names(aa) <- 1:length(aa)
str(nonAmbiguousNum(aa))
str(nonAmbiguousNum(aa,uniq=FALSE,asLi=TRUE))

[Package wrMisc version 1.15.1 Index]