tieorder {truecluster} | R Documentation |
This function works very similar to order
but in case of ties it breaks them by random.
tieorder(x, decreasing = FALSE, index = seq(along = x), tiebreak = TRUE)
x |
a vector of double or integer |
decreasing |
TRUE to order decreasing (default FALSE = increasing) |
index |
optionally a vector of integer index to be rearranged |
tiebreak |
FALSE to avoid randomly breaking ties |
NAs sorted last. Uses internally rsort_index.
index rearranged
Jens Oehschlägel
tieorder(c(NA, NA, 2, 2, 1)) tieorder(c(NA, NA, 2, 2, 1)) tieorder(c(NA, NA, 2, 2, 1)) tieorder(c(NA, NA, 2, 2, 1)) x <- c(NA, NA, 2, 2, 1) n <- 100 o <- integer(length(x)) for (i in 1:n) o <- o + tieorder(x) o/n