Re: [R] Retrieving matrix column and row names by index value

2012-03-29 Thread R. Michael Weylandt
This seems to work: namesFromIndex <- function(indx, obj){ mapply(`[`, dimnames(obj), arrayInd(indx, dim(obj))) } Michael On Thu, Mar 29, 2012 at 2:20 PM, Lanna Jin wrote: > Hi all, > > So let's say I have a matrix, mdat and I only know the index number. How do > I retrieve the column and r

[R] Retrieving matrix column and row names by index value

2012-03-29 Thread Lanna Jin
Hi all, So let's say I have a matrix, mdat and I only know the index number. How do I retrieve the column and row names? For example, > mdat <- matrix(c(1,2,3, 11,12,13), nrow = 2, ncol=3, byrow=TRUE, dimnames = list(c("row1", "row2"), c("C.1", "C.2"