[R] cannot assign dimnames

Jan Goebel jgoebel at diw.de
Mon Sep 27 17:08:03 CEST 2004


Dear Dan,

a simple example:

> mat<-matrix(1:6, ncol=3)
> mat
     [,1] [,2] [,3]
[1,]    1    3    5
[2,]    2    4    6
> dimnames(mat)<-list(1:2, 1:3)
> mat
  1 2 3
1 1 3 5
2 2 4 6
> dimnames(mat)<-list(1:2, letters[1:3])
> mat
  a b c
1 1 3 5
2 2 4 6
> dimnames(mat)
[[1]]
[1] "1" "2"

[[2]]
[1] "a" "b" "c"

dimnames need a list!

HIH

jan


On Mon, 27 Sep 2004, Dan Bebber wrote:

> 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 OX1 3RB
> UK
> Tel. 01865 275000
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

-- 
+-----------------------------------------
 Jan Goebel 
 j g o e b e l @ d i w . d e

 DIW Berlin 
 German Socio-Economic Panel Study (GSOEP) 
 Königin-Luise-Str. 5
 D-14195 Berlin -- Germany --
 phone: 49 30 89789-377
+-----------------------------------------




More information about the R-help mailing list