[Rd] Bug reporting system inquiry plus a bug report related to sort

Tom Short tshort.rlists at gmail.com
Thu Mar 4 16:29:48 CET 2010


Is the bug-reporting system working okay? Two days ago, I submitted
the following bug report via email to r-bugs at r-project.org. I didn't
see a confirmation, and it didn't see it at
http://bugs.r-project.org/. Now, http://bugs.r-project.org/ seems to
be down.

Anyway, here's the bug report related to sort.list and sort(...,
index.return = TRUE) with na.last = NA


I think that both sort.list(x, na.last = NA) and sort(x, na.last = NA,
index.return = TRUE)$ix give incorrect answers with na.last. With
na.last, both of these return answers equivalent to
sort.list(na.omit(x)), and I think they should be the equivalent of
order(x, na.last=NA) as follows.

> x <- c(1L, 6L, NA, 2L)
> order(x, na.last = NA) # right
[1] 1 4 2
> sort.list(x, na.last = NA, method = "radix") # wrong, I think
[1] 1 3 2
> sort.list(x, na.last = NA, method = "quick") # wrong
[1] 1 3 2
> sort(x, na.last = NA, index.return = TRUE)$ix # wrong
[1] 1 3 2

I've included a patch for the "radix" and "shell" methods of
sort.list. The sort and "quick" method of sort.list (which uses sort)
look more challenging. With the patch, I get:

> sort.list(x, na.last = NA, method = "radix") # good
[1] 1 4 2
> sort.list(x, na.last = NA, method = "shell") # good
[1] 1 4 2
> sort.list(x, na.last = NA, method = "quick") # still bad
[1] 1 3 2

By the way, having the radix sort is great. It's really fast for factors.

- Tom

Tom Short
Electric Power Research Institute (EPRI)



> sessionInfo()
R version 2.10.1 (2009-12-14)
i386-pc-mingw32

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base


More information about the R-devel mailing list