[R] Setting matrix dimnames in a list

statmobile statmobile at gmail.com
Thu May 8 19:33:46 CEST 2008


Hey All,

I was wondering if I could solicit a little input on what I'm trying to 
do here.  I have a list of matrices, and I want to set their dimnames, 
but all I can come up with is this:

x <- matrix(1:4,2)
y <- matrix(5:8,2)

z <- list(x,y)
nm <- c("a","b")
nms <- list(nm,nm)

z <- lapply(z,function(x)dimnames(x)<-nms)

As you can see, this doesn't quite work.  Could anybody help me, and 
bonus points if you can help me do this efficiently.  Please cc my email 
address, because I only get summaries of the list.

Thanks in advance!



More information about the R-help mailing list