Suppose I have a vector of integers such as:
> x [1] 1 1 1 4 4 13 13 14
I am looking for an efficient way in R to rescale the vecto
Try the following command, assuming that v is your vector
v
rank( v )
see ?rank for more information.
?rank
Well, this does give another result, but is correct as ranking, which is what I thought you want to achieve. To get your preferred result, do
as.integer( factor( v ) )