From arunkumar.sriniv at gmail.com  Thu Jan  8 13:46:57 2015
From: arunkumar.sriniv at gmail.com (Arunkumar Srinivasan)
Date: Thu, 8 Jan 2015 13:46:57 +0100
Subject: [Rd] On base::rank
Message-ID: <CAJ=vYTHRCgOMbVZw1jmFN-fEwdZL1p8JW9nYS+8yBFhsrZoP-Q@mail.gmail.com>

Have a look at the following, taken from base::rank:

...
    if (!is.na(na.last) && any(nas)) {
        yy <- integer(length(x)) # <~~~~~~~~~
        storage.mode(yy) <- storage.mode(y) # <~~~~~~~~
        yy <- NA
        NAkeep <- (na.last == "keep")
        if (NAkeep || na.last) {
            yy[!nas] <- y
            if (!NAkeep)
                yy[nas] <- (length(y) + 1L):length(yy)
        }
...

Alternatively, look at lines 36 and 37 here:
https://github.com/wch/r-source/blob/fbf5cdf29d923395b537a9893f46af1aa75e38f3/src/library/base/R/rank.R#L36

There seems to be no need for those lines, IIUC. Isn't it? 'yy' is
replaced with NA in the ver next line.

Best,
Arun.



[Rd] On base::rank
Arunkumar Srinivasan