>>>>> Suharto Anggono Suharto Anggono >>>>> on Wed, 4 Mar 2026 06:05:18 +0000 (UTC) writes:> Then, please announce the change in NEWS. For example: > The result of arithmetic and comparison operations of non-overlapping "ts" objects where either is a matrix is now a matrix. > It seems that the statement "diff(<ts-matrix>) remains matrix, even when it has length zero" was meant for the change to 'Ops.ts'. But the wording is about diff(<ts-matrix>), which is included in the previous statement. > But I've just realized this. > Suppose that > x <- ts(0) > With the change, x - lag(x, -1) and x == lag(x, -1) are NULL. > In R 4.5.2, x - lag(x, -1) is integer(0) and x == lag(x, -1) is logical(0). Indeed, so we may even have to change R-devel further (for this rare boundary case). But the R 4.5.2 x - lag(x, -1) giving integer(0) is only somewhat better than giving NULL when in principle the "truly correct" answer should be double(0) and we'd rather get that right in R-devel. Re NEWS, you are right: I will add a small note, indeed {as it is not "code" that's frozen}. Martin > ________ > On Tuesday, 3 March 2026 at 04:02:14 pm GMT+7, Martin Maechler <maechler at stat.math.ethz.ch> wrote:>>>>> Peter Dalgaard>>>>>> ? ? on Mon, 2 Mar 2026 14:37:22 +0100 writes: > ? ? > I do hope Martin sees this. Code freeze for 4.5.3 is > ? ? > Wednesday @0:02 ...? - Peter > Yes, I did see and think about it, but decided that it was "too > late" now, *and* not a "problem" I think: > `-` now exhibits the correct behaviour? but the diff() > ? ? methods do not yet (but do in R-devel etc). > Martin > ? ? >> On 28 Feb 2026, at 12.57, Suharto Anggono Suharto Anggono > ? ? >> via R-devel <r-devel at r-project.org> wrote: > ? ? >> > ? ? >> Now that the NEWS item is gone from "CHANGES IN R 4.5.2 > ? ? >> patched", please also revert the change to 'Ops.ts' in > ? ? >> R-4-5-branch, as I have mentioned. In R-4-5-branch, the > ? ? >> change makes diff(m) inconsistent with m - lag(m, -1) for > ? ? >> 1-row ts matrix m. Previously, neither of them was a > ? ? >> matrix. > ? ? >> > ? ? >> _______ On Monday, 23 February 2026 at 07:16:36 pm GMT+7, > ? ? >> Martin Maechler <maechler at stat.math.ethz.ch> wrote: > ? ? >> > ? ? >> > ? ? >>>>>>> Suharto Anggono Suharto Anggono via R-devel on Sun, > ? ? >>>>>>> 22 Feb 2026 03:58:13 +0000 (UTC) writes: > ? ? >> > ? ? >> > diff(m, lag, dif) for matrix m now still returns > > ? ? >> matrices, also when lag * dif > nrow(m) (PR#18972, thanks > ? ? >> to > Mikael Jagan and Suharto Anggono).? > > ? ? >> diff(<ts-matrix>) remains matrix, even when it has length > ? ? >> zero. > ? ? >> > ? ? >> > The above NEWS item has been moved to "CHANGES IN R > ? ? >> 4.5.2 patched". > ? ? >> > ? ? >> > In fact, in R-4-5-branch, diff(m, lag, dif) for matrix > ? ? >> m is still not a matrix when lag * dif > nrow(m) (see > ? ? >> https://svn.r-project.org/R/branches/R-4-5-branch/src/library/base/R/diff.R > ? ? >> for 'diff.default'; > ? ? >> https://svn.r-project.org/R/branches/R-4-5-branch/src/library/base/R/datetime.R > ? ? >> for 'diff.POSIXt'; > ? ? >> https://svn.r-project.org/R/branches/R-4-5-branch/src/library/base/R/dates.R > ? ? >> for 'diff.Date'; > ? ? >> https://svn.r-project.org/R/branches/R-4-5-branch/src/library/stats/R/ts.R > ? ? >> for 'diff.ts'). > ? ? >> > ? ? >> > And I suggest keeping it so. Because it has been like > ? ? >> that simce the beginning, I think changing it in a patch > ? ? >> release is not appropriate. > ? ? >> > ? ? >> We have ported bug fixes of "forever bugs" to the "R > ? ? >> patched branch", before, quite on purpose.? Typically > ? ? >> they have been really rare use cases and for that reason > ? ? >> probably were not detected and reported earlier... and we > ? ? >> (R core) still thought these bugs should disappear as > ? ? >> quickly as possible. > ? ? >> > ? ? >> For the above reason(s), I *had* actually planned to port > ? ? >> this bug fix also to R "4.5.2 patched" ...? But then it > ? ? >> has become somewhat late to do the port only now, and R > ? ? >> 4.5.3 will only be a "wrap up" release anyway.. > ? ? >> > ? ? >> Hence, I agree with your opinion and will now move the > ? ? >> NEWS entry instead of porting the bug fix which was the > ? ? >> original plan. > ? ? >> > ? ? >> Martin > ? ? >> > ? ? >> > ? ? >> > What have been ported to R-4-5-branch are just- > ? ? >> replacing 'tsLag' with 'lag' in 'diff.ts'- 'Ops.ts' to > ? ? >> return matrix when e1 or e2 is matrix but e1 and e2 are > ? ? >> not overlapping > I suggest reverting the port. A > ? ? >> justification of diff(m) for 1-row ts matrix m not being > ? ? >> a matrix was that m - lag(m, -1) was not a matrix.? > > ? ? >> Replacing 'tsLag' with 'lag' in 'diff.ts' is actually OK, > ? ? >> but not necessary. > ? ? >> > ? ? >> [[alternative HTML version deleted]] > ? ? >> > ? ? >> ______________________________________________ > ? ? >> R-devel at r-project.org mailing list > ? ? >> https://stat.ethz.ch/mailman/listinfo/r-devel > ? ? > -- > ? ? > Peter Dalgaard, Professor, Center for Statistics, > ? ? > Copenhagen Business School Solbjerg Plads 3, 2000 > ? ? > Frederiksberg, Denmark Phone: (+45)38153501 Office: A 4.23 > ? ? > Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com > [[alternative HTML version deleted]]
Martin Maechler
2026-Mar-04 11:57 UTC
[Rd] diff(<ts-matrix>), Ops.ts -- R Bugzilla PR#18972
>>>>> Martin Maechler >>>>> on Wed, 4 Mar 2026 12:42:20 +0100 writes:>>>>> Suharto Anggono Suharto Anggono >>>>> on Wed, 4 Mar 2026 06:05:18 +0000 (UTC) writes:>> Then, please announce the change in NEWS. For example: >> The result of arithmetic and comparison operations of non-overlapping "ts" objects where either is a matrix is now a matrix. >> It seems that the statement "diff(<ts-matrix>) remains matrix, even when it has length zero" was meant for the change to 'Ops.ts'. But the wording is about diff(<ts-matrix>), which is included in the previous statement. >> But I've just realized this : >> Suppose that >> x <- ts(0) >> With the change, x - lag(x, -1) and x == lag(x, -1) are NULL. >> In R 4.5.2, x - lag(x, -1) is integer(0) and x == lag(x, -1) is logical(0). > Indeed, so we may even have to change R-devel further (for this > rare boundary case). > But the R 4.5.2 x - lag(x, -1) giving integer(0) is only somewhat better than > giving NULL when in principle the "truly correct" answer should > be double(0) and we'd rather get that right in R-devel. ==> So, we should probably reopen R Bugzilla item PR#18972, at ---> https://bugs.r-project.org/show_bug.cgi?id=18972 Martin