> Georgi Boshnakov
> on Wed, 9 Sep 2020 10:48:56 + writes:
> I think that this is because `[<-` dispatches on S4
> methods only if the first argument is S4. ?"[<-" says:
> "These operators are also implicit S4 generics, but as
> primitives, S4 methods will be dispatched only on S4
> objects ‘x’."
> Georgi Boshnakov
Yes, exactly, very well found, Georgi!
This is something I would have wanted different for years,
exactly because of several such problems with the Matrix
package of which I'm the maintainer.
Long time ago I had also looked if I saw how to fix this
behavior inside 'methods' (i.e. the S4 infrastructure pkg)
and I think in this case also, inside R's basic C code.
At the time (~ 10 yrs ago) I gave up, but don't remember why.
I'm happy if you create a formal bug report, possibly "wishlist"
as it is documented behavior, for this infelicity...
and then I will probably add the 'HELPWANTED' keyword.
Martin
> -Original Message-
> Message: 19 Date: Tue, 8 Sep 2020 22:04:44 -0400 From: Ben
> Bolker To: r-devel
> Subject: [Rd] more Matrix
> weirdness Message-ID:
>
> Content-Type: text/plain; charset="utf-8"; Format="flowed"
>Am I being too optimistic in expecting this (mixing and
> matching matrices and Matrices) to work? If x is a matrix
> and m is a Matrix, replacing a commensurately sized
> sub-matrix of x with m throws "number of items to replace
> is not a multiple of replacement length" ...
> x <- matrix(0,nrow=3,ncol=10,
> dimnames=list(letters[1:3],LETTERS[1:10])) rr <-
> c("a","b","c") cc <- c("B","C","E") m <-
> Matrix(matrix(1:9,3,3)) x[rr,cc] <- m
> cheers Ben Bolker
> --
> Message: 20 Date: Wed, 9 Sep 2020 07:03:47 +0100 From: Rui
> Barradas To: Ben Bolker
> , r-devel
> Subject: Re: [Rd] more Matrix weirdness Message-ID:
> <7037975c-22b6-6eca-d871-743eead53...@sapo.pt>
> Content-Type: text/plain; charset="utf-8"; Format="flowed"
> Hello,
> R 4.0.2 on Ubuntu 20.04, sessionInfo() below.
> I can reproduce this, sort of. The error I'm getting is
> different:
> x[rr, cc] <- m #Error in x[rr, cc] <- m : replacement has
> length zero
> But if I check lengths and dimensions, they are
> identical().
> identical(length(x[rr, cc]), length(m)) #[1] TRUE
> identical(dim(x[rr, cc]), dim(m)) #[1] TRUE
> What works is
> x[rr, cc] <- as.matrix(m)
> I ran Ben's code on RStudio 1.3.1073, the following is run
> with Rscript and the error message is the same.
> rui@rui:~$ Rscript --vanilla rhelp.R R version 4.0.2
> (2020-06-22) Platform: x86_64-pc-linux-gnu (64-bit)
> Running under: Ubuntu 20.04.1 LTS
> Matrix products: default BLAS:
> /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 LAPACK:
> /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
> locale: [1] LC_CTYPE=pt_PT.UTF-8 LC_NUMERIC=C [3]
> LC_TIME=pt_PT.UTF-8 LC_COLLATE=pt_PT.UTF-8 [5]
> LC_MONETARY=pt_PT.UTF-8 LC_MESSAGES=pt_PT.UTF-8 [7]
> LC_PAPER=pt_PT.UTF-8 LC_NAME=C [9] LC_ADDRESS=C
> LC_TELEPHONE=C [11] LC_MEASUREMENT=pt_PT.UTF-8
> LC_IDENTIFICATION=C
> attached base packages: [1] stats graphics grDevices utils
> datasets methods base
> other attached packages: [1] Matrix_1.2-18
> loaded via a namespace (and not attached): [1]
> compiler_4.0.2 grid_4.0.2 lattice_0.20-41 Error in x[rr,
> cc] <- m : number of items to replace is not a multiple of
> replacement length Execution halted
> Hope this helps,
> Rui Barradas
> Às 03:04 de 09/09/20, Ben Bolker escreveu:
>> Am I being too optimistic in expecting this (mixing and
>> matching matrices and Matrices) to work? If x is a
>> matrix and m is a Matrix, replacing a commensurately
>> sized sub-matrix of x with m throws "number of items to
>> replace is not a multiple of replacement length" ...
>>
>> x <- matrix(0,nrow=3,ncol=10,
>> dimnames=list(letters[1:3],LETTERS[1:10])) rr <-
>> c("a","b","c") cc <- c("B","C","E") m <-
>> Matrix(matrix(1:9,3,3)) x[rr,cc] <- m
>>
>> cheers Ben Bolker
>>
>> __
>> R-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
> --
> Message: 21 Date: Wed, 9 Sep 2020 08:27:06 +0200 From: Uwe
> Ligges To:
> r-devel@r-project.org Subject: Re: [Rd] failing automatic
> incoming check Message-ID:
>
> Content-Type: text/plain; charset="utf-8"; Format="flowed"
> On 08.09.2020 21:34, Sebastian P. Luque wrote:
>> Hello,
>>
>> I got a notification regarding a failure to pass incoming
>> checks automatically after a CRAN submission. The
>> details are given here:
>>
>>
http