[R] use row and col names of a matrix to create colnames of a new one.

Juan Antonio Balbuena balbuena at uv.es
Thu Aug 30 16:24:33 CEST 2012


Hello
I would appreciate any help with the following: 
Given a matrix with col and row names, such as
> matrix1 <- matrix(rnorm(16),4)
> rownames(matrix1) <- LETTERS(1:4)
> colnames(matrix1) <- letters[1:4]
> matrix1
           a           b            c          d
A  1.6845882 -0.27809792 -0.874798414 -0.2143993
B -0.9283862 -1.50640703 -0.723568218 -0.4716539
C -1.6945380 -0.12336987  0.003299728  0.1413674
D -0.2715407 -0.05752609 -0.310539234 -1.1146264

I need to create a new matrix whose colnames are A-a, B-b, C-c and D-d. So
the col and rownames of matrix1 are separated by an hyphen.

It is probably very simple, but cannot find the way.

Thank you very much for your time.






--
View this message in context: http://r.789695.n4.nabble.com/use-row-and-col-names-of-a-matrix-to-create-colnames-of-a-new-one-tp4641829.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list