R-alpha: dimnames<- bug

Thomas Lumley (thomas@biostat.washington.edu)
Tue, 10 Sep 1996 15:12:05 -0700 (PDT)


Date: Tue, 10 Sep 1996 15:12:05 -0700 (PDT)
From: Thomas Lumley <thomas@biostat.washington.edu>
To: r-testers@stat.math.ethz.ch
Subject: R-alpha: dimnames<- bug
In-Reply-To: <Pine.SUN.3.91.960910144520.27995C-100000@chekov>

dimnames<- has problems with the column names of a dataframe

> a<-matrix(1:10,nrow=5)
> a<-data.frame(a)
> a
     a.1 a.2
[1,]   1   6
[2,]   2   7
[3,]   3   8
[4,]   4   9
[5,]   5  10
> dimnames(a)[[2]]<-c("a","b")
Error: memory exhausted
>

dimnames()[[1]]<-  appears to work ok, as does assigning both row and 
column names at once.  It also works correctly on arrays or matrices.
>dimnames(a)[[1]]<-c("a","b","c","d","e")
> a
  a.1 a.2
a   1   6
b   2   7
c   3   8
d   4   9
e   5  10
> dimnames(a)
[[1]]
[1] "a" "b" "c" "d" "e"

[[2]]
[1] "a.1" "a.2"

> dimnames(a)[[2]]
[1] "a.1" "a.2"
> dimnames(a)<-list(c("a","b","c","d","e"),c("1","2"))
 


thomas lumley       Penguin: the name is supposed to come from 
PhD student         the Welsh _pen_gwyn_ meaning "white head". 
Biostatistics       As penguins have black heads and do not live 
U. Washington       within 10000 miles of Wales it is difficult 
Seattle WA 98195    to see how this theory arose.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- To (un)subscribe, send
subscribe	or	unsubscribe
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-