>>>>> Arunkumar Srinivasan <arunkumar.sriniv at gmail.com>
>>>>> on Thu, 8 Jan 2015 13:46:57 +0100 writes:
> 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.
Indeed. Interesting that nobody has noticed till now,
even though that part has been world readable since at least 2008-08-25.
Note that the R source code is at
http://svn.r-project.org/R/
and the file in question at
http://svn.r-project.org/R/trunk/src/library/base/R/rank.R
where you can already see the new code
(given that 'x' was no longer needed, there's no need for
'xx').
Martin Maechler,
ETH Zurich