View source: R/nonAmbiguousMat.R
nonAmbiguousMat | R Documentation |
nonAmbiguousMat
makes values of matrix 'mat' in col 'byCol' unique.
nonAmbiguousMat(
mat,
byCol,
uniqOnly = FALSE,
asList = FALSE,
nameMod = "amb_",
callFrom = NULL
)
mat |
numeric or character matrix (or data.frame), column specified by 'byCol' must be/will be used as.numeric, 1st column of 'mat' will be considered like index & used for adding prefix 'nameMod' (unless byCol=1, then 2nd col will be used) |
byCol |
(character or integer-index) column by which ambiguousity will be tested |
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 result as list |
nameMod |
(character) prefix added to 1st column of 'mat' (expect 'by') for indicating non-unique/ambiguous values |
callFrom |
(character) allow easier tracking of message(s) produced |
sorted non-ambigous numeric vector (or list if 'asList'=TRUE and 'uniqOnly'=FALSE)
for non-numeric use firstOfRepeated
- but 1000x much slower !; get1stOfRepeatedByCol
set.seed(2017); mat2 <- matrix(c(1:100,round(rnorm(200),2)),ncol=3,
dimnames=list(1:100,LETTERS[1:3]));
head(mat2U <- nonAmbiguousMat(mat2,by="B",na="_",uniqO=FALSE),n=15)
head(get1stOfRepeatedByCol(mat2,sortB="B",sortS="B"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.