When there are ties in the original data, is there a way to create a ranking without gaps in the ranks (consecutive, integer rank values)? Suppose:
x <-
I can think of a quick function to do this. It's not optimal with a for loop but it works:)
x=c(1,1,2,3,4,5,8,8) foo <- function(x){ su=sort(unique(x)) for (i in 1:length(su)) x[x==su[i]] = i return(x) } foo(x) [1] 1 1 2 3 4 5 6 6