0

I have two matrix which are are of same dimension what i wanted achieve is getting row and col of one matrix replace with other

matrix1=

      exam1 exam2 exam3 exam4
 arun  10     10   15    18
 joy    2     2     5     6

matrix2=

       "v1"   "v2"  "v3" "v3"
  "1"   12     13    15    16
  "2"   10     12    13    13

output= I wanted replace matrix2 row name and column name with matrix1

       exam1 exam2 exam3 exam4
  arun   12     13    15    16
  joy    10     12    13    13

can anyone suggest me how can I do, new to R note: matrix files are very large

1 Answers1

2

You could transfer the column names using dimnames<-

dimnames(matrix2) <- dimnames(matrix1)

which does the job of

rownames(matrix2) <- rownames(matrix1)
colnames(matrix2) <- colnames(matrix1)
Ronak Shah
  • 377,200
  • 20
  • 156
  • 213