Displaying 20 results from an estimated 10000 matches similar to: "the real dimnames"
2010 Jul 29
1
Using 'dimname names' in aperm() and apply()
I think that the "dimname names" of tables and arrays could make
aperm() and apply() (and probably some other functions) easier to use.
(dimname names are, for example, created by table() )
The use would be something like:
--
x <-table( from=sample(3,100,rep=T), to=sample(5,100,rep=T))
trans <- x / apply(x,"from",sum)
y <- aperm( trans,
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
1998 Sep 09
2
diag() losing dimnames
Using diag() to extract the diagonal of a matrix loses all but the first dimname
(R 0.62.3). The problem seems to be in [ ]:
>
> x <- matrix(1:9,3,3)
> dimnames(x) <- list(c("a", "b", "c"), c("a", "b", "c"))
> x
a b c
a 1 4 7
b 2 5 8
c 3 6 9
> diag(x)
a NA NA
1 5 9
> x[c(1,5,9)]
a NA NA
1 5 9
>
Paul
1999 Jul 20
2
tensor() function and sets
Hi Everyone,
To complete the outer() and kronecker() functions in the base, may I
suggest the following tensor() function, which allows the multiplication
of arrays through sets of conformable dimensions. I am happy to write a
help page if required.
The code also needs a setdiff() function which prompts me to ask: what
about simple set functions? I expect many of us have written our own
2010 Apr 18
3
xtabs() of proportions, and naming a dimension (not a row)
Hi,
xtabs() creates a table of counts. I want a table of proportions -- that
is, I want to divide every vector (along a particular dimension) by its sum.
The tiny example below does that. The call to xtabs() creates a matrix "A"
with dimensions ("x1","x2","y"). I transform "A" using aperm() and aaply()
to get the matrix "B". The
2009 Jun 22
3
Calculating "row standard deviations"
Hi R-helpers,
I have been struggling with calculating row and column statistics,
e.g. standard deviation.
I know that
> datac$Mean<-rowMeans(datac,na.rm=TRUE)
will give me row means.
I have tried to replicate those row means with the apply function:
> datac$Mean2<-apply(datac,2,mean)
so that I can replace the function argument with "sd" (instead of
mean) to get standard
2005 Jan 06
1
arrays emerging from tapply
The code below illustrates some points about results from tapply that
I find strange. I wonder if they are intended and if so why it is so.
1) When you make a table the dimnames is a *named* list, tapply
returns an unnamed list.
2) data.frame behaves differently on an array and a table. Is this
an intended feature?
3) For tables class(TAB) and attr(TAB,"class") both return
2002 Jan 30
1
mosaicplot(formula, data)--- bugged?
I have been tinkering with mosaicplot() and friends as a way
of learning R. As part of this, I've written a pair.table()
method for mosaic matrices, and would like to extend mosaicplot
to work with loglin and logln (MASS) objects. I'm using
R 1.4.0 on Win 98.
I've been trying to figure out the formula interface, and think
there's a bug, but not sure how to find it, yet alone fix
2000 Jun 25
1
renaming columns
I frequently get data sets with cryptically-named variables. The datasets
are more useful to me with informative variable names. I know that I can
rename variables using the following command:
dimname(dataset[[2]][index.of.variable.to.be.renamed]<-new.variable.name
If I want to do this inside a function (say something I call RenameCol)
what is the best way to communicate the
2013 Jul 04
1
Modificar una función de un paquete
Muchas gracias Javier,
Lo que yo quiero es cambiar el título de la leyenda que dice "Pearson
residuals" a español "Residuales de Pearson", pero no me doy cuenta como.
También en lugar de "p-value", que diga "Valor de P". Es posible?
Manuel
2013/7/4 Marcuzzi, Javier Rubén <javier.ruben.marcuzzi@gmail.com>
> Estimado Manuel Spíndola
>
>
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
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,
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
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),
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
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
>
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
2009 May 17
1
[wishlist, patch] make row() and col() preserve dimnames (PR#13705)
Full_Name: Ben Goodrich
Version: 2.9.0
OS: Linux (Debian unstable)
Submission from: (NULL) (128.103.220.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]
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
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