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)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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)

Henrik Bengtsson-5
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

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: 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)

Michael Lawrence-3
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
<[hidden email]> 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
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel