Skip to content
Back to formatted view

Raw Message

Message-ID: <1116522062.428cc64ecdb0a@webmail.cs.wisc.edu>
Date: 2005-05-19T17:01:02Z
From: Alejandro Munoz del Rio
Subject: reason for na.last=TRUE in rank

Dear UseRs,

Could someone explain to me why the default behaviour of rank() is to assign the
largest rank to missing data

> rank(c(3, 1, NA))
[1] 2 1 3

as opposed to what I would hazard would be the expected 2, 1, NA? 

Despite consistency being the hobgoblin of little minds, of two
closely related functions one handles NAs in the same way (order())
but another one doesn't (sort()). order() also uses the "NA last" rule
by default, whereas sort() removes NAs.

alejandro