Re: [R] Unexpected result after auto-attaching of the Matrix package

2025-02-13 Thread H B via R-help
Hi Jeff, you are obviously right and I would usually load packages before, but in this case it was a saved R object that I had not created, and therefore did not know what to expect. I was prepared to get an error message, but not getting an error or at least a warning and then getting the wrong

Re: [R] Unexpected result after auto-attaching of the Matrix package

2025-02-13 Thread H B via R-help
Dear  Ivan, thanks a lot for the detailed analysis. This is excellent  and answers my question. Unfortunately it is difficult to find any documentation on this topic. I now understand this is not a formal library  auto-loading feature. What I still see as problematic is that in this way one can

Re: [R] Unexpected result after auto-attaching of the Matrix package

2025-02-12 Thread Ivan Krylov via R-help
В Tue, 11 Feb 2025 13:51:48 +0100 H B via R-help пишет: > > class(d) > [1] "dgCMatrix" > attr(,"package") > [1] "Matrix" > > dim(d) > Loading required package: Matrix > NULL Here's what happens here: 1. .Primitive("dim") considers dispatching a dim() method: https://github.com/r-devel/r-s

Re: [R] Unexpected result after auto-attaching of the Matrix package

2025-02-11 Thread Jeff Newmiller via R-help
Why aren't you loading the package before you load the object that assumes the relevant methods for that object are available? On February 11, 2025 4:51:48 AM PST, H B via R-help wrote: >Dear all, > >I just stumbled on this behavior - not sure if this is expected: > >R version 4.4.2 (2024-10-31

[R] Unexpected result after auto-attaching of the Matrix package

2025-02-11 Thread H B via R-help
Dear all, I just stumbled on this behavior - not sure if this is expected: R version 4.4.2 (2024-10-31) -- "Pile of Leaves" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu > library(Matrix) > sparseMatrix(i=1:10, j=1:10, x=rnorm(10)) |> saveRDS("~/Do