Henrik Bengtsson
2016-Aug-25 23:39 UTC
[Rd] sort.int(c(2, NA, 4), index.return=TRUE, na.last=NA, method)$ix differ for method="radix" and "shell"/"quick" (+ new default in R-devel)
Does sort.int(c(2,NA,4), index.return=TRUE, na.last=NA, method="radix")$ix give the intended result, because I get:> sort.int(c(2,NA,4), index.return=TRUE, na.last=NA, method="radix")$x [1] 2 4 $ix [1] 1 3 With method="shell" and method="quick" in R devel, I get:> sort.int(c(2,NA,4), index.return=TRUE, na.last=NA, method="shell")$x [1] 2 4 $ix [1] 1 2> sort.int(c(2,NA,4), index.return=TRUE, na.last=NA, method="quick")$x [1] 2 4 $ix [1] 1 2 Is this correct? Should we expect sort.int(c(2,NA,4), index.return=TRUE, na.last=NA)$ix to be the same regardless of 'method'? BACKGROUND: I recently discovered that some of my package tests on functions using sort(x, index.return=TRUE) where double 'x' may contain missing values fails. I traced it down to the update in R-devel (2016-08-2? r70856) where method="radix" became the new default; svn log -r 70856 ------------------------------------------------------------------------ r70856 | lawrence | 2016-06-29 16:59:30 -0700 (Wed, 29 Jun 2016) | 3 lines radix is default sort algorithm for doubles (no more rounding), grouping() puts NAs last. which I think is why we in R devel now observe:> sort(c(2,NA,4), index.return=TRUE)$x [1] 2 4 $ix [1] 1 3 whereas prior to this we saw:> sort(c(2,NA,4), index.return=TRUE)$x [1] 2 4 $ix [1] 1 2 /Henrik
Michael Lawrence
2016-Aug-26 00:55 UTC
[Rd] sort.int(c(2, NA, 4), index.return=TRUE, na.last=NA, method)$ix differ for method="radix" and "shell"/"quick" (+ new default in R-devel)
The radix sort should be consistent with the others, i.e., it should behave like sort.list(), not order(). I will correct this. On Thu, Aug 25, 2016 at 4:39 PM, Henrik Bengtsson <henrik.bengtsson at gmail.com> wrote:> Does sort.int(c(2,NA,4), index.return=TRUE, na.last=NA, > method="radix")$ix give the intended result, because I get: > >> sort.int(c(2,NA,4), index.return=TRUE, na.last=NA, method="radix") > $x > [1] 2 4 > > $ix > [1] 1 3 > > With method="shell" and method="quick" in R devel, I get: > >> sort.int(c(2,NA,4), index.return=TRUE, na.last=NA, method="shell") > $x > [1] 2 4 > > $ix > [1] 1 2 > >> sort.int(c(2,NA,4), index.return=TRUE, na.last=NA, method="quick") > $x > [1] 2 4 > > $ix > [1] 1 2 > > Is this correct? Should we expect sort.int(c(2,NA,4), > index.return=TRUE, na.last=NA)$ix to be the same regardless of > 'method'? > > > > BACKGROUND: > > I recently discovered that some of my package tests on functions using > sort(x, index.return=TRUE) where double 'x' may contain missing values > fails. I traced it down to the update in R-devel (2016-08-2? r70856) > where method="radix" became the new default; > > svn log -r 70856 > ------------------------------------------------------------------------ > r70856 | lawrence | 2016-06-29 16:59:30 -0700 (Wed, 29 Jun 2016) | 3 lines > > radix is default sort algorithm for doubles (no more rounding), > grouping() puts NAs last. > > which I think is why we in R devel now observe: > >> sort(c(2,NA,4), index.return=TRUE) > $x > [1] 2 4 > > $ix > [1] 1 3 > > whereas prior to this we saw: > >> sort(c(2,NA,4), index.return=TRUE) > $x > [1] 2 4 > > $ix > [1] 1 2 > > /Henrik >
Reasonably Related Threads
- Bug reporting system inquiry plus a bug report related to sort
- [PATCH v17 2/6] radix tree test suite: add tests for xbitmap
- [PATCH v17 2/6] radix tree test suite: add tests for xbitmap
- [Bug 547] Missing radix.o in makefile for AFS
- support for radix order() over entire range of integers