head/tail breaking change

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

head/tail breaking change

Jan Gorecki
Hi R-devel community,

I am aware of changes in R-devel in head/tail methods but I was not
expecting that to be a breaking change.

# R 3.6.1
ar = array(1:27, c(3,3,3))
tail(ar, 1)
#[1] 27

The current output of R-devel is something that I would expect from a

tail(ar, c(1, Inf, Inf))

or

tail(ar, c(1, NA, NA))

calls.
Is it going to stay like this or there are plans to mitigate this
breaking change?

# R-devel 2019-12-17 r77592
ar = array(1:27, c(3,3,3))
tail(ar, 1)
#, , 1
#
#     [,1] [,2] [,3]
#[3,]    3    6    9
#
#, , 2
#
#     [,1] [,2] [,3]
#[3,]   12   15   18
#
#, , 3
#
#     [,1] [,2] [,3]
#[3,]   21   24   27

Best,
Jan Gorecki

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

Re: head/tail breaking change

Gabriel Becker-2
Jan,

That is an intentional change as you can see in the documentation for
head/tail in R-devel. Last time I discussed it with Martin, this behavior
was desired and thus is unlikely to change unless "our" (ie his) mind does.

The hope is that the new behavior is actually what people would want (note
it already behaves this way for data.frames and for matrices, which are now
explicitly array objects with 2 dimensions as well as classed as matrices,
so its more consistent now, and more reasonable for the object).

Best,
~G

On Wed, Dec 18, 2019 at 2:44 AM Jan Gorecki <[hidden email]> wrote:

> Hi R-devel community,
>
> I am aware of changes in R-devel in head/tail methods but I was not
> expecting that to be a breaking change.
>
> # R 3.6.1
> ar = array(1:27, c(3,3,3))
> tail(ar, 1)
> #[1] 27
>
> The current output of R-devel is something that I would expect from a
>
> tail(ar, c(1, Inf, Inf))
>
> or
>
> tail(ar, c(1, NA, NA))
>
> calls.
> Is it going to stay like this or there are plans to mitigate this
> breaking change?
>
> # R-devel 2019-12-17 r77592
> ar = array(1:27, c(3,3,3))
> tail(ar, 1)
> #, , 1
> #
> #     [,1] [,2] [,3]
> #[3,]    3    6    9
> #
> #, , 2
> #
> #     [,1] [,2] [,3]
> #[3,]   12   15   18
> #
> #, , 3
> #
> #     [,1] [,2] [,3]
> #[3,]   21   24   27
>
> Best,
> Jan Gorecki
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

        [[alternative HTML version deleted]]

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

Re: head/tail breaking change

Jan Gorecki
Thank you Gabriel,
I agree that new behaviour makes much more sense. Just wanted to confirm
before resolving compatibility of my unit tests.
Best,
Jan

On Wed 18 Dec, 2019, 10:46 PM Gabriel Becker, <[hidden email]> wrote:

> Jan,
>
> That is an intentional change as you can see in the documentation for
> head/tail in R-devel. Last time I discussed it with Martin, this behavior
> was desired and thus is unlikely to change unless "our" (ie his) mind does.
>
> The hope is that the new behavior is actually what people would want (note
> it already behaves this way for data.frames and for matrices, which are now
> explicitly array objects with 2 dimensions as well as classed as matrices,
> so its more consistent now, and more reasonable for the object).
>
> Best,
> ~G
>
> On Wed, Dec 18, 2019 at 2:44 AM Jan Gorecki <[hidden email]> wrote:
>
>> Hi R-devel community,
>>
>> I am aware of changes in R-devel in head/tail methods but I was not
>> expecting that to be a breaking change.
>>
>> # R 3.6.1
>> ar = array(1:27, c(3,3,3))
>> tail(ar, 1)
>> #[1] 27
>>
>> The current output of R-devel is something that I would expect from a
>>
>> tail(ar, c(1, Inf, Inf))
>>
>> or
>>
>> tail(ar, c(1, NA, NA))
>>
>> calls.
>> Is it going to stay like this or there are plans to mitigate this
>> breaking change?
>>
>> # R-devel 2019-12-17 r77592
>> ar = array(1:27, c(3,3,3))
>> tail(ar, 1)
>> #, , 1
>> #
>> #     [,1] [,2] [,3]
>> #[3,]    3    6    9
>> #
>> #, , 2
>> #
>> #     [,1] [,2] [,3]
>> #[3,]   12   15   18
>> #
>> #, , 3
>> #
>> #     [,1] [,2] [,3]
>> #[3,]   21   24   27
>>
>> Best,
>> Jan Gorecki
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>

        [[alternative HTML version deleted]]

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

Re: head/tail breaking change

Martin Maechler
>>>>> Jan Gorecki
>>>>>     on Thu, 19 Dec 2019 11:49:11 +0530 writes:

    > Thank you Gabriel,
    > I agree that new behaviour makes much more sense. Just wanted to confirm
    > before resolving compatibility of my unit tests.
    > Best,
    > Jan

Indeed, Gabe's explanation is right-on-spot:  With the
generalization of head() / tail(), we really found it undesirable to
stay "internally inconsistent".

We do have to grab the chance for not-quite-back-compatible
improvements -- when the costs look comparably small --  for R 4.0.0.

Martin

    > On Wed 18 Dec, 2019, 10:46 PM Gabriel Becker, <[hidden email]> wrote:

    >> Jan,
    >>
    >> That is an intentional change as you can see in the documentation for
    >> head/tail in R-devel. Last time I discussed it with Martin, this behavior
    >> was desired and thus is unlikely to change unless "our" (ie his) mind does.
    >>
    >> The hope is that the new behavior is actually what people would want (note
    >> it already behaves this way for data.frames and for matrices, which are now
    >> explicitly array objects with 2 dimensions as well as classed as matrices,
    >> so its more consistent now, and more reasonable for the object).
    >>
    >> Best,
    >> ~G
    >>
    >> On Wed, Dec 18, 2019 at 2:44 AM Jan Gorecki <[hidden email]> wrote:
    >>
    >>> Hi R-devel community,
    >>>
    >>> I am aware of changes in R-devel in head/tail methods but I was not
    >>> expecting that to be a breaking change.
    >>>
    >>> # R 3.6.1
    >>> ar = array(1:27, c(3,3,3))
    >>> tail(ar, 1)
    >>> #[1] 27
    >>>
    >>> The current output of R-devel is something that I would expect from a
    >>>
    >>> tail(ar, c(1, Inf, Inf))
    >>>
    >>> or
    >>>
    >>> tail(ar, c(1, NA, NA))
    >>>
    >>> calls.
    >>> Is it going to stay like this or there are plans to mitigate this
    >>> breaking change?
    >>>
    >>> # R-devel 2019-12-17 r77592
    >>> ar = array(1:27, c(3,3,3))
    >>> tail(ar, 1)
    >>> #, , 1
    >>> #
    >>> #     [,1] [,2] [,3]
    >>> #[3,]    3    6    9
    >>> #
    >>> #, , 2
    >>> #
    >>> #     [,1] [,2] [,3]
    >>> #[3,]   12   15   18
    >>> #
    >>> #, , 3
    >>> #
    >>> #     [,1] [,2] [,3]
    >>> #[3,]   21   24   27
    >>>
    >>> Best,
    >>> Jan Gorecki
    >>>
    >>> ______________________________________________
    >>> [hidden email] mailing list
    >>> https://stat.ethz.ch/mailman/listinfo/r-devel
    >>>
    >>

    > [[alternative HTML version deleted]]

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

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