similar to: dim<-() changed in R-devel; no longer removing "dimnames" when doing dim(x) <- dim(x)

Displaying 20 results from an estimated 3000 matches similar to: "dim<-() changed in R-devel; no longer removing "dimnames" when doing dim(x) <- dim(x)"

2023 Oct 30
2
dim<-() changed in R-devel; no longer removing "dimnames" when doing dim(x) <- dim(x)
>>>>> Henrik Bengtsson >>>>> on Sun, 29 Oct 2023 10:42:19 -0700 writes: > Hello, > the fix of PR18612 > (https://bugs.r-project.org/show_bug.cgi?id=18612) in > r85380 > (https://github.com/wch/r-source/commit/2653cc6203fce4c48874111c75bbccac3ac4e803) > caused a change in `dim<-()`. Specifically, in the past,
2023 Oct 31
1
dim<-() changed in R-devel; no longer removing "dimnames" when doing dim(x) <- dim(x)
Hi Martin, Henrik, I actually like this change. Makes a lot of sense IMO that dim(x) <- dim(x) be a no-op, or, more generally, that foo(x) <- foo(x) be a no-op for any setter/getter combo. FWIW S4Arrays::set_dim() does that too. It also preserves the dimnames if the right value is only adding or dropping outermost (ineffective) dimensions: ??? > x <- array(1:6, dim=c(2,3,1),
2017 Jun 06
0
surprisingly, S4 classes with a "dim" or "dimnames" slot are final (in the Java sense)
Thanks for the report. The issue is that one cannot set special attributes like names, dim, dimnames, etc on S4 objects. I was aready working on this and will have a fix soon. > a2 <- new("A2") > dim(a2) <- c(2, 3) Error in dim(a2) <- c(2, 3) : invalid first argument On Mon, Jun 5, 2017 at 6:08 PM, Herv? Pag?s <hpages at fredhutch.org> wrote: > Hi, > >
2017 Jun 06
1
surprisingly, S4 classes with a "dim" or "dimnames" slot are final (in the Java sense)
I've fixed this and will commit soon. Disregard my dim<-() example; that behaves as expected (the class needs a dim<-() method). Michael On Tue, Jun 6, 2017 at 5:16 AM, Michael Lawrence <michafla at gene.com> wrote: > Thanks for the report. The issue is that one cannot set special attributes > like names, dim, dimnames, etc on S4 objects. I was aready working on this >
2017 Jun 06
2
surprisingly, S4 classes with a "dim" or "dimnames" slot are final (in the Java sense)
Hi, It's nice to be able to define S4 classes with slots that correspond to standard attributes: setClass("A1", slots=c(names="character")) setClass("A2", slots=c(dim="integer")) setClass("A3", slots=c(dimnames="list")) By doing this, one gets a few methods for free: a1 <- new("A1", names=letters[1:3])
2012 Jun 04
2
Convert 2-dim array to 3-dim array
Hello R-users, I'd like to load data from a CSV-file to a 3-dimensional array. However the default seems to be 2-dimensional. It would also be ok to load the data and then convert it to a 3-dimensional structure. I've been trying: dat = read.csv(filename) myArr = as.array(dat, dim = c(12,100,3)) However, I get an error message: Error in `dimnames<-.data.frame`(`*tmp*`,
1997 Jul 15
0
R-beta: dimnames(obj)[..] <- .... works in S but not in R
The following is a minor incompatibility R <-> S which may be worth putting on the TASKS list : -- Martin Maechler ###--- The following code only works in S, but not in R : ##-- Example 1 : dimnames(..)[.] <- list(...) ## === ma <- cbind(1,1:4) dimnames(ma)[2] <- list(c("x","y")) ma ##- x y ##- [1,] 1 1 ##- [2,] 1 2
2016 Jun 10
0
collapsing list of NULLs dimnames into a NULL
Hi, Here are two different ways to create a 0 x 0 logical matrix: m1 <- matrix(nrow=0, ncol=0) m1 # <0 x 0 matrix> m2 <- as.matrix(data.frame()) m2 # <0 x 0 matrix> Surprisingly: identical(m1, m2) # [1] FALSE That's because of their dimnames: dimnames(m1) # NULL dimnames(m2) # [[1]] # NULL # # [[2]] # NULL More
2020 Feb 19
0
dimnames incoherence?
>>>>> Serguei Sokol >>>>> on Wed, 19 Feb 2020 15:21:21 +0100 writes: > Hi, > I was bitten by a little incoherence in dimnames assignment or may be I > missed some point. > Here is the case. If I assign row names via dimnames(a)[[1]], when > nrow(a)=1 then an error is thrown. But if I do the same when nrow(a) > 1 >
2015 Dec 17
1
array() ignores illegal non-list dimnames
Is there a reason that array() silently ignores dimnames that are not a list but matrix() gives an error? > str(matrix(11:14, 2, 2, dimnames=c("Rows","Cols"))) Error in matrix(11:14, 2, 2, dimnames = c("Rows", "Cols")) : 'dimnames' must be a list > str(array(11:14, dim=c(2, 2), dimnames=c("Rows","Cols"))) int
2003 Jan 30
0
empty array indexing with dimnames -> erroneous error (PR#2507)
This is a bug that will not often trigger, and only happens for arrays (but not matrices) ending up with 0 dimensions: The following code also shows two 'buglets' (the first even for matrix indexing) where "drop = TRUE/FALSE" is not correctly obeyed. One can argue that since all these arrays have length zero, it shouldn't matter what dimensions they get. [But this
2017 Dec 22
0
Unexpected dimnames attribute returned by cbind/rbind
Hi, > m5 <- cbind(integer(5), integer(5)) > m5 [,1] [,2] [1,] 0 0 [2,] 0 0 [3,] 0 0 [4,] 0 0 [5,] 0 0 > dimnames(m5) NULL No dimnames, as expected. > m0 <- cbind(integer(0), integer(0)) > m0 [,1] [,2] > dimnames(m0) [[1]] NULL [[2]] NULL Unexpected dimnames attribute!
2008 Dec 03
1
Matrix dimnames crash (PR#13361)
In Windows XP, the matrix() function crashes the program when 'dimnames' is an empty list: matrix(1:4, nrow=2, dimnames=list()) # R has encountered a problem and needs to close ... This bug is specific to WinXP, as Linux64 handles this situation more gracefully: matrix(1:4, nrow=2, dimnames=list()) Error in matrix(1:4, nrow = 2, dimnames = list()) : invalid type
2005 Feb 11
0
Subsetting using dimnames on S4 array-based class
Hello, I am encountering some problems when overloading the "[" operator for a new S4 class based on array. This is an example class definition: setClass("foo", representation("array"), prototype(array(NA, dim=c(3,3)), dimnames=list(age=1:3, year=10:12)) ) And this the corresponding setMethod with print estatements to see what is being passed:
2007 Sep 27
0
Unnecessary extra copy with matrix(..., dimnames=NULL) (Was: Re: modifying large R objects in place)
As others already mentioned, in your example you are first creating an integer matrix and the coercing it to a double matrix by assigning (double) 1 to element [1,1]. However, even when correcting for this mistake, there is an extra copy created when using matrix(). Try this in a fresh vanilla R session: > print(gc()) used (Mb) gc trigger (Mb) max used (Mb) Ncells 136684 3.7
2007 May 13
0
Error in dimnames(x) <- dn
Hi everyone, I import data from access, and make an object (c) store the data, when I want to use it in function mnp, it gives the below error: Error in dimnames(x) <- dn : length of 'dimnames' [2] not equal to array extent > x<-odbcConnectAccess("db2.mdb") > c<-sqlFetch(x,"Sheet2") > odbcClose(x) > c choice clio punto polo 1
2017 Jun 02
0
subletting an array according to dimnames
Have you tried P2["20", "10", "0"] ? Jean On Thu, Jun 1, 2017 at 3:10 PM, li li <hannah.hlx at gmail.com> wrote: > Hi all, > I have a three dimensional array with the corresponding dimension names. > I would like to subset the array according to the dimension names. For > example, > suppose I want to extract the values corresponding to A=20,
1999 Oct 08
1
dimnames and subscripting (PR#293)
I am not sure that this is a bug, but it was unexpected -- of course my expectations are fallible, eg column ordering in model.matrix()! When an array is subscripted the names of the dimnames list are lost (v 64.1). fred <- array(1:12, 2:4, list(A = letters[1:2], B = letters[3:5], C = letters[6:9])) dimnames(fred) dimnames(fred[1, , ]) dimnames(fred[1, , , drop=FALSE]) In the first
2006 May 12
1
Dropping dimnames doesn't matter (anymore)?
In the "old days", one way of speeding up matrix calculations was to drop the dimnames of the matrices prior to the calculations, i.e., dimnames(X) <- NULL. I distinctly remember that this could have a great impact at least in Splus 3.x (under UNIX/Linux). I just did a small, informal test of this with a couple of functions I use to fit plsr models, in R 2.3.0 (Linux). It
2004 Nov 22
1
Left justification af dimnames in tables.
Hi helpeRs. When I do two-ways tables dimnames in columns are almost left-adjusted: <- factor(rbinom(30,1,.3),labels=c("first","second")) > b <- a > table(a,b) b a first second first 21 0 second 0 9 If I do a oneway table however, dimnames are right-adjusted: table(a) a first second 21 9 Actually I must admit I