I am wondering if something trivial is missing here:
When ranking a vector like NS, there are four options for how to handle NS:
x<-c(5, NA, 3, NA, 6, 9, 10, NA, 5, 7, 12) rank(x, na.last=T) # [1] 2.5 9.0 1.0 10.0 4.0 6.0 7.0 11.0 2.5 5.0 8.0 rank(x, na.last=F) # [1] 5.5 1.0 4.0 2.0 7.0 9.0 10.0 3.0 5.5 8.0 11.0 rank(x, na.last=NA) # [1] 2.5 1.0 4.0 6.0 7.0 2.5 5.0 8.0 rank(x, na.last="keep") # [1] 2.5 NA 1.0 NA 4.0 6.0 7.0 NA 2.5 5.0 8.0
I want to save and evaluate the National Assembly. For my purposes, they should be the same and the last. In this situation, the ties.method to be used is the default value of "average". I am looking for this result:
# [1] 2.5 10.0 1.0 10.0 4.0 6.0 7.0 10.0 2.5 5.0 8.0
From the "rank" help: "NA values ββare never considered equal: for na.last = TRUE and na.last = FALSE they are given different ranks in the order in which they occur in x."
So, it seems that I want to - that is, treat them the same way, and an average rank as the last rank is impossible with rank . It's true - is there a simple way to achieve this through rank? Do I have to rely on the second line of code to re-set the rank of NA after doing rank(x, na.last="keep") ?
source share