search for: dimnam

Displaying 20 results from an estimated 1983 matches for "dimnam".

Did you mean: dimname
2023 Oct 29
1
dim<-() changed in R-devel; no longer removing "dimnames" when doing dim(x) <- dim(x)
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, any `dim<-()` assignment would _always_ remove "dimnames" and "names" attributes per help("dim"): The replacement method changes the "dim" attribute (provided the new value is compatible) and removes any "dimnames" and "names" attributes. In the new version, assigning the same "dim"...
2023 Oct 30
2
dim<-() changed in R-devel; no longer removing "dimnames" when doing dim(x) <- dim(x)
...gt; (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, > any `dim<-()` assignment would _always_ remove "dimnames" > and "names" attributes per help("dim"): > The replacement method changes the "dim" attribute > (provided the new value is compatible) and removes any > "dimnames" and "names" attributes. > In the n...
2012 Aug 13
4
dimnames in an array(I'll be grateful if this message will be passed to all list users)
...39;ve got an array: y1=rnorm(41,0.2) y2=rnorm(41,0.2) y3=rbind(y1,y2) data11<-array(0,c(41,2,2)) data11[,1,]=y3 data11[,2,]=y3 rownames(data11)<-rownames(data11, do.NULL = FALSE, prefix = "Obs.") colnames=c("V","R") varnames=c("one","two") dimnames(data11)<-list(rownames(data11), varnames, colnames) data11a<-as.array(data11, dimnames=dimnames(data11)) The analysis that I would like to do with R(CollocInfer) runs as follows(I print for the sake of introduction here though to run this line of code requires extensive setup) res11a =...
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), dimnames=list(c("A", "B"), c("x","y", "z"), "T")) ??? > S4Arrays:::set_dim(x, 2:3) ? ? ? x y z ??? A 1...
2020 Feb 19
3
dimnames incoherence?
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 it's OK. Is one of this case works unexpectedly? Both? Neither? a=as.matrix(1) dimnames(a)[[1]]="a&...
2004 Sep 27
8
cannot assign dimnames
Dear list, If anyone knows how to assign dimnames to matrices or arrays I would be most grateful for help. I've tried various permutations of likely-looking code but get error messages every time. I could find no example in the documentation. Many thanks, Dan Bebber Department of Plant Sciences University of Oxford South Parks Road Oxford...
2007 Dec 18
4
accessing dimension names
I have a matrix y: > dimnames(y) $x93 [1] "1" "2" $x94 [1] "0" "1" "2" .................. so on (there are other dimensions as well) I need to access a particular dimension, but a random mechanism tells me which dimension it would. So, sometimes I might need to access dim...
2005 Oct 15
1
drop() and "["(), and apply()
I have two queries about the behaviour of drop() and apply() regarding the dimnames and names(dimnames) of the answer. I would appreciate any comments on this behaviour. I will submit any of this as a bug report if I am encouraged to do so. The first query, concerning drop(), seems to me to be a bug in ?drop, and possibly also in the function. ?drop: [...] Any accompanying...
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...
2001 Aug 07
1
cannot assign to NULL dimnames (PR#1042)
Full_Name: Hsiu-Khuern Tang Version: 1.3.0 OS: GNU/Linux (Debian unstable) Submission from: (NULL) (192.6.19.124) Hi all, I am not sure this is a bug rather than an intentional design, but here goes: If I do > a <- matrix(1:4, nrow=2) > dimnames(a)[[1]] <- c("a", "b") I get the following error message because dimnames(a) is NULL: Error: more elements supplied than there are to replace What is the proper way to do this? I know this works: > dimnames(a) <- list(c("a", "b"), NULL) In...
2008 Jan 04
3
slow access to matrix dimnames
hello, i have been trying to convert my data frames to matrices in the hopes of speeding up some of my more complicated scripts. to assist with this, i am trying to create a "matrix column operator" like $: "%$%" = function(data,field) { as.numeric(data[,grep(field,unlist(dimnames(data)[2]))]) } the idea here is that you can use a matrix like a dataframe: matrix%$%"fieldname" i am getting this matrix by converting a dataframe: df = read.csv("data.csv") matrix = data.matrix(df,rownames.force=FALSE) this sets rownames to "NULL", but there is...
2012 Nov 15
4
Selecting the "non-attribute" part of an object
I have two matrices, generated by R functions that I don't understand. I want to confirm that they're the same, but I know that they have different attributes. If I want to compare the dimnames, I can say > identical(attr(tm, "dimnames"), attr(tmm, "dimnames")) [1] FALSE or even: > identical(dimnames(tm), dimnames(tmm)) [1] FALSE But I can't find any good way to compare the "main" part of objects. What I'm doing now is: > tm_new <-...
2020 Feb 19
2
dimnames incoherence?
>>>>> Martin Maechler >>>>> on Wed, 19 Feb 2020 18:06:57 +0100 writes: >>>>> 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 >> it's OK. Is one of this case works unexpectedly? Both...
2017 Jun 01
2
subletting an array according to dimnames
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, B=10, C=0. I know I can do: P2[dimnames(P2)$A==20, dimnames(P2)$B==10, dimnames(P2)$C==0] But is there a better way for doing this? Thanks for your help! Hanna > dimnames(P2) $A [1] "20" "25" "30" "35" "40" $B [1] "5" "10" "15" "20" &...
2009 May 17
1
[wishlist, patch] make row() and col() preserve dimnames (PR#13705)
...20.16) row(x), col(x), and functions that call them like lower.tri(x) and upper.tri(x) do not retain the rownames or colnames of x in the matrix that is returned. Example from R version 2.9.0 : x <- matrix(1:9, nrow = 3, ncol = 3) rownames(x) <- LETTERS[1:3] colnames(x) <- letters[1:3] dimnames(row(x)) # NULL dimnames(col(x)) # NULL Is there anyone for whom the expected behavior is to drop the dimnames of x ? It is not consistent with other functions of matrices. By default, row(x) already returns the row numbers of x (and similarly for col()), so how would seeing integers in the rowna...
2011 Apr 20
1
Error in dimnames(x) for Poisson EWMA model
I am attempting to run a Poisson EWMA model using Patrick Brandt's source code. I get the following error when I run the code: Error in dimnames(x) <- dn : length of 'dimnames' [1] not equal to array extent Dimnames(x) looks like this: [[1]] NULL [[2]] [1] "mip" "div" "nom" "unity" "mood" "times" [7] "hmajparty" "smaj...
2010 Aug 23
3
extracting p-values from Anova objects (from the car library)
Dear all, is there anyone who can help me extracting p-values from an Anova object from the car library? I can't seem to locate the p-values using str(result) or str(summary(result)) in the example below > A <- factor( rep(1:2,each=3) ) > B <- factor( rep(1:3,times=2) ) > idata <- data.frame(A,B) > fit <- lm( cbind(a1_b1,a1_b2,a1_b3,a2_b1,a2_b2,a2_b3) ? sex,
2011 May 16
1
Extracting the dimnames of an array with variable dimensions
Hi list, In a function I am writing, I need to extract the dimension names of an array. I know this can be acheived easily using dimnames() but my problem is that I want my function to be robust when the number of dimensions varies. Consider the following case: foo <- array(data = rnorm(32), dim = c(4,4,2), dimnames=list(letters[1:4], LETTERS[1:4], letters[5:6])) # What I want is to extract the *names of the dimensions* for wh...
2012 Aug 08
1
dimnames in array
...c(41,2,2)) m8<-cbind(.29,1:41) m9<-as.array(m8,dim=c(41,2)) data11[,1,] = y+m9 data11[,2,] = y+m9 rownames(data2, do.NULL = FALSE, prefix="row") varnames=c("V","R") colnames(data6)=c("one","two") colnames(data10)=colnames(data6) dimnames(data11)=list(rownames(data2),varnames,colnames(data10)) data11a<-as.array(data11,dimnames=dimnames(data11)) attributes(data11a) #so this seems to print out the array attributes as they should be: two sets of two columns each, and the first column of each set is called 'v' and the se...
2005 Dec 08
1
kronecker(... , make.dimnames=TRUE)
Hi I'm using kronecker() with a matrix and a vector. I'm interested in the column names that kronecker() returns: > a <- matrix(1:9,3,3) > rownames(a) <- letters[1:3] > colnames(a) <- LETTERS[1:3] > b <- c(x=1,y=2) > kronecker(a,b,make.dimnames=TRUE) A: B: C: a:x 1 4 7 a:y 2 8 14 b:x 2 5 8 b:y 4 10 16 c:x 3 6 9 c:y 6 12 18 > The column names are undesirable for me as I don't want the extra colon. The following code is a version of kronecker() that does not exhibit this behaviour. It tests nchar() of the dim...