Re: [Rd] How setClass() may introduce a binary dependency between packages

2025-01-18 Thread Mikael Jagan
See my proposal in this mailing list from July 2023 where I documented the same problem: [Rd] proposal for WRE: clarify that use of S4 classes implies use of superclasses https://stat.ethz.ch/pipermail/r-devel/2023-July/082739.html Indeed, many of the caching problems would be avoide

[Rd] 'else' on new line not parsed at top level as part of preceding 'if'

2024-12-02 Thread Mikael Jagan
I wonder if there is room for improvement here: > str2lang("if (a) b1else b0") if (a) b1 else b0 > str2lang("if (a) b1 \n else b0") Error in str2lang("if (a) b1 \n else b0") : :2:2: unexpected 'else' 1: if (a) b1 2: else ^ It only occurs at top level. When t

Re: [Rd] 'else' on new line not parsed at top level as part of preceding 'if'

2024-12-02 Thread Mikael Jagan
rdoch On 2024-12-02 10:56 a.m., Mikael Jagan wrote: I wonder if there is room for improvement here: > str2lang("if (a) b1else b0") if (a) b1 else b0 > str2lang("if (a) b1 \n else b0") Error in str2lang("if (a) b1 \n else b0&qu

Re: [Rd] changes in R-devel and zero-extent objects in Rcpp

2024-06-10 Thread Mikael Jagan
it's absolutely possible > that I'm just confused at this point; I don't have a super-simple > example to show you at the moment. The closest is this example by Mikael > Jagan: https://github.com/lme4/lme4/issues/794#issuecomment-2155093049 > > whic

Re: [Rd] Should c(..., recursive = TRUE) and unlist(x, recursive = TRUE) recurse into expression vectors?

2024-04-27 Thread Mikael Jagan
On 2024-04-27 10:53 am, Mikael Jagan wrote: Reading the body of function 'AnswerType' in bind.c, called from 'do_c' and 'do_unlist', I notice that EXPRSXP and VECSXP are handled identically in the recurse = TRUE case. A corollary is that c(recursive = TRUE)

[Rd] Should c(..., recursive = TRUE) and unlist(x, recursive = TRUE) recurse into expression vectors?

2024-04-27 Thread Mikael Jagan
Reading the body of function 'AnswerType' in bind.c, called from 'do_c' and 'do_unlist', I notice that EXPRSXP and VECSXP are handled identically in the recurse = TRUE case. A corollary is that c(recursive = TRUE) and unlist(recursive = TRUE) treat expression vectors like expression(a, b)

Re: [Rd] Matrix 1.6.2+ versus Matrix 1.6.2-

2023-11-22 Thread Mikael Jagan
Naras, Thanks. I'm a bit confused, because Rmosek does not declare Matrix as a dependency: > tools::package_dependencies("Rmosek", which = "all")[[1L]] [1] "pkgbuild" nor does it contain code needing compilation: > packageDescription("Rmosek", fields="NeedsCompilation") [1] "n

Re: [Rd] R-4.3 version list.files function could not work correctly in chinese

2023-11-22 Thread Mikael Jagan
FWIW, a user on Stack Overflow just reported the same issue with list.files running R 4.3.z on Windows. They do not observe the issue running R-devel, with Tomas' patch (r84960). It is still the case that their file names did not exceed 260 wide characters. https://stackoverflow.com/q/77527

Re: [Rd] c(NA, 0+1i) not the same as c(as.complex(NA), 0+1i)?

2023-11-09 Thread Mikael Jagan
On 2023-11-09 3:13 am, Martin Maechler wrote: Mikael Jagan on Wed, 8 Nov 2023 11:13:18 -0500 writes: > So, to summarize, the open questions are: > (1) Should as.complex(NA_character_) give complex(r=NA_real_, i=0) > instead of NA_complex_? > (2) Shou

Re: [Rd] c(NA, 0+1i) not the same as c(as.complex(NA), 0+1i)?

2023-11-08 Thread Mikael Jagan
So, to summarize, the open questions are: (1) Should as.complex(NA_character_) give complex(r=NA_real_, i=0) instead of NA_complex_? (2) Should the first argument in c(NA, x) and c(NA_integer_, x), where typeof(x) == "complex", be promoted to complex(r=NA_real_, i=0)

Re: [Rd] as(, "dgTMatrix")' is deprecated.

2023-10-04 Thread Mikael Jagan
> There is a call to mosek and I assumed that this wasn’t going to be helpful for most R-devel recipients. I tried Duncan’s very reasonable suggestion about options() but it didn’t produce the desired error, so perhaps this isn’t really a warning but something else??? > The details are descr

Re: [Rd] Recent changes to as.complex(NA_real_)

2023-09-23 Thread Mikael Jagan
And I think there are quite a few other situations where looking at Re() and Im() separately makes a lot of sense. Indeed, and there is no way to "tell" BLAS and LAPACK to treat both the real and imaginary parts as NA_REAL when either is NA_REAL. Hence the only reliable way to implement

Re: [Rd] Recent changes to as.complex(NA_real_)

2023-09-22 Thread Mikael Jagan
On 2023-09-22 6:38 am, Martin Maechler wrote: Mikael Jagan on Thu, 21 Sep 2023 00:47:39 -0400 writes: > Revisiting this thread from April: > https://stat.ethz.ch/pipermail/r-devel/2023-April/082545.html > where the decision (not yet backported) was

[Rd] Recent changes to as.complex(NA_real_)

2023-09-20 Thread Mikael Jagan
Revisiting this thread from April: https://stat.ethz.ch/pipermail/r-devel/2023-April/082545.html where the decision (not yet backported) was made for as.complex(NA_real_) to give NA_complex_ instead of complex(r=NA_real_, i=0), to be consistent with help("as.complex") and as.complex(NA) and

Re: [Rd] R-devel Digest, Vol 246, Issue 6

2023-08-07 Thread Mikael Jagan
Two quite related and recent threads on R-devel: [1] proposal for WRE: clarify that use of S4 classes implies use of superclasses https://stat.ethz.ch/pipermail/r-devel/2023-July/082739.html [2] Should package version requirements assume installation from sources? https://stat.ethz.ch/pipermail/r

[Rd] proposal for WRE: clarify that use of S4 classes implies use of superclasses

2023-07-19 Thread Mikael Jagan
If a package has importClassesFrom(P, C) in its NAMESPACE, then should it _also_ have importClassesFrom(P, ) importClassesFrom(Q, ) ## and so on ... ? I think that WRE could be more clear on this point, and in any case I _think_ that the answer is yes. Notably, I think that t

Re: [Rd] logic tweak needed for as.data.frame. deprecation warning

2023-07-06 Thread Mikael Jagan
change to using as.data.frame.vector. I glanced at the other non-deprecated as.data.frame. and did not see other usage of the deprecated ones ... a more systematic check could be worth doing. Mikael On 2023-07-06 11:32 am, Mikael Jagan wrote: Continuing the thread started on R-package-devel, here:

[Rd] logic tweak needed for as.data.frame. deprecation warning

2023-07-06 Thread Mikael Jagan
Continuing the thread started on R-package-devel, here: https://stat.ethz.ch/pipermail/r-package-devel/2023q3/009307.html The logic of the now soft-deprecated as.data.frame., > body(as.data.frame.integer)[[2L]] if ((sys.nframe() <= 1L || sys.call(-1L)[[1L]] != quote(as.data.frame)) && nzchar

Re: [Rd] New behavior when running script in package directory?

2023-06-21 Thread Mikael Jagan
Surely this behaviour is just a case of ESS being "too clever", sourcing *.R files in special way when it detects that a file belongs to a package (loading dependencies automatically, etc.)? The function ss() is defined inside of .ess.source(), which is defined here: https://github.com/emacs-ess

Re: [Rd] codetools wrongly complains about lazy evaluation in S4 methods

2023-06-15 Thread Mikael Jagan
other parameters, usually have not place in the signature of the generic. H. On 6/14/23 20:57, Mikael Jagan wrote: Thanks all - yes, I think that Simon's diagnosis ("user error") is correct: in this situation one should define a reasonable generic function explicitly, with a call t

Re: [Rd] codetools wrongly complains about lazy evaluation in S4 methods

2023-06-14 Thread Mikael Jagan
it should only be part of the method implementation. If one was to implement the same default behavior in the generic itself (not necessarily a good idea) the default would be ncol = if (complete) nrow(qr.R(qr, TRUE)) else min(dim(qr.R(qr, TRUE))) to not rely on the internals of the impleme

Re: [Rd] codetools wrongly complains about lazy evaluation in S4 methods

2023-06-12 Thread Mikael Jagan
eless, that's the intended approach as far as i know. Best, ~G On Wed, Jun 7, 2023 at 1:07 AM Serguei Sokol via R-devel < r-devel@r-project.org> wrote: Le 03/06/2023 à 17:50, Mikael Jagan a écrit : In a package, I define a method for not-yet-generic function 'qr.X' like so:

[Rd] Rd macros are not expanded inside of \eqn{} or \deqn{}

2023-06-12 Thread Mikael Jagan
I was a bit surprised to learn that, if one has an Rd file as below: %% zzz.Rd \newcommand{\zzz}{whatever} \name{zzz} \title{zzz} \description{ \zzz{} \eqn{\zzz{}} \deqn{\zzz{}} } then the macro is _not_ expanded inside of \eqn{} or \deqn{} when parsed to text or HTML. Is th

[Rd] codetools wrongly complains about lazy evaluation in S4 methods

2023-06-03 Thread Mikael Jagan
In a package, I define a method for not-yet-generic function 'qr.X' like so: > setOldClass("qr") > setMethod("qr.X", signature(qr = "qr"), function(qr, complete, ncol) NULL) The formals of the newly generic 'qr.X' are inherited from the non-generic function in the base namespace. Notabl

[Rd] Change DEFAULTDEPARSE to DEFAULTDEPARSE | SHOWATTRIBUTES ?

2023-05-06 Thread Mikael Jagan
The deparse options used by default by 'deparse' and 'dput' are c("keepNA", "keepInteger", "niceNames", "showAttributes") but Defn.h still has #define DEFAULTDEPARSE 1089 /* KEEPINTEGER | KEEPNA | NICE_NAMES, used for calls */ i.e., with the SHOWATTRIBUTES bit turned off. Is that o

Re: [Rd] sum(), min(), max(), prod() vs. named arguments in ...

2023-04-18 Thread Mikael Jagan
On 2023-04-15 6:00 am, r-devel-requ...@r-project.org wrote: Date: Fri, 14 Apr 2023 13:38:00 +0300 From: Ivan Krylov To:r-devel@r-project.org Subject: [Rd] sum(), min(), max(), prod() vs. named arguments in ... Message-ID: <20230414133800.75383dae-6792@arachnoid> Content-Type: text/plain; ch

[Rd] Time to add is.formula() to 'stats'?

2023-04-07 Thread Mikael Jagan
I know that it has been discussed in the past, but I wanted to ask to revisit the idea of exporting is.formula <- function(x) inherits(x, "formula") from 'stats', parallel to is.data.frame() in 'base', given how widely formulae are used these days in conjunction with data frames, even outside

Re: [Rd] det(diag(c(NaN, 1))) should be NaN, not 0

2023-03-16 Thread Mikael Jagan
https://netlib.org/lapack/lapack-3.11.0.html It is possible that the underlying issue in DGETRF (INFO>0 due to NaN pivots rather than 0 pivots {=> singular}) still exists for matrices less trivial than my 2-by-2 examples. Will have to experiment ... Mikael On 2022-11-09 3:58 pm, Mikael Jagan wr

[Rd] Regenerate m4/gettext.m4 with updated AM_GNU_GETTEXT?

2023-02-16 Thread Mikael Jagan
Currently, m4/gettext.m4 contains an old version of Autoconf macro AM_GNU_GETTEXT relying on internal symbols (e.g., _nl_expand_alias) to detect broken implementations of GNU gettext. System libraries are searched for the internal symbols unconditionally, i.e., even when linking against a static

Re: [Rd] solve.default(a, b) should not ignore names(dimnames(.))

2022-11-10 Thread Mikael Jagan
On 2022-11-10 1:10 pm, Mikael Jagan wrote: Hello, Currently, solve.default() is defined such that > identical(dimnames(solve.default(a, b)), list(dimnames(a)[[2L]], dimnames(b)[[2L]])) is always TRUE, i.e., ignoring names(dimnames(a)) and names(dimnames(b)). Hence we

[Rd] solve.default(a, b) should not ignore names(dimnames(.))

2022-11-10 Thread Mikael Jagan
Hello, Currently, solve.default() is defined such that > identical(dimnames(solve.default(a, b)), list(dimnames(a)[[2L]], dimnames(b)[[2L]])) is always TRUE, i.e., ignoring names(dimnames(a)) and names(dimnames(b)). Hence we see: > a <- b <- diag(2L) > dimnames(a) <- list(A1 = c("a

[Rd] det(diag(c(NaN, 1))) should be NaN, not 0

2022-11-09 Thread Mikael Jagan
Hello, Currently, determinant(A) calculates the determinant of 'A' by factorizing A=LU and computing prod(diag(U)) [or the logarithm of the absolute value]. The factorization is done by LAPACK routine DGETRF, which gives a status code INFO, documented [1] as follows: *> INFO is INTEGER

[Rd] Should package version requirements assume installation from sources?

2022-09-13 Thread Mikael Jagan
[Arguably also appropriate for R-package-devel, but posted to R-devel as the discussion is aimed primarily at "experts" ... ] We, the authors of Matrix, have encountered a somewhat subtle issue induced by caching of S4 classes and methods in package namespaces. The namespaces of three revers

Re: [Rd] Subsetting "dspMatrix" without coercion to "matrix"

2021-11-17 Thread Mikael Jagan
This seems entirely avoidable, given that there is a relatively simple formula for converting 2-ary indices [i,j] of S to 1-ary indices k of S[lower.tri(S, TRUE)]: k <- i + round(0.5 * (2L * n - j) * (j - 1L)) # for i >= j I ought to be slightly more precise here: _coercion_ is avoidable, be

[Rd] Subsetting "dspMatrix" without coercion to "matrix"

2021-11-17 Thread Mikael Jagan
Currently, the class for dense symmetric matrices in packed storage, "dspMatrix", inherits its subset (i.e., `[`) methods from the "Matrix" class. As a result, subsetting "dspMatrix" requires coercion to "matrix". If memory cannot be allocated for this "matrix", then an error results. n <- 30