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

David Winsemius dwinsemius at comcast.net
Thu Aug 30 16:55:37 CEST 2012


On Aug 30, 2012, at 7:24 AM, Juan Antonio Balbuena wrote:

>> matrix1 <- matrix(rnorm(16),4)
>> rownames(matrix1) <- LETTERS[1:4] # fixed the coding error
>> colnames(matrix1) <- letters[1:4]

  matrix2 <- matrix1
  colnames(matrix2) <-  
paste(rownames(matrix1),colnames(matrix1),sep="-")
  matrix2

-- 
David Winsemius, MD
Alameda, CA, USA




More information about the R-help mailing list