Answers.Body: <p>Since they share the ensembl_ID column, you can merge them, then assign the symbol column to the rownames, then delete the symbol column.</p>
  
  <p>something like:</p>
  
  <pre><code>merged &lt;- merge(mat1, mat2, by = 0) 
  rownames(merge) &lt;- merged[,'symbol'] 
  merged[,symbol] &lt;- NULL
  </code></pre>
  
  <p><a href="https://stat.ethz.ch/R-manual/R-devel/library/base/html/merge.html" rel="nofollow noreferrer">https://stat.ethz.ch/R-manual/R-devel/library/base/html/merge.html</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-19T22:46:19.973Z
Answers.LastActivityDate: 2019-03-19T22:46:19.973Z
Answers.UserDisplayName: swbarnes2
Body: <p>I have two matrices; I want to convert the row names of first matrix to gene symbol from matched ensemble=gene symbol from second matrix</p>
  
  <pre><code>&gt; head(mat1[,1:2])
                  TCGA-L5-A4OG-11A-12R-A260-31
  ENSG00000000003                         1818
  ENSG00000000005                            0
  ENSG00000000419                         1436
  ENSG00000000457                         1175
  ENSG00000000460                          242
  ENSG00000000938                          536
                  TCGA-IC-A6RE-11A-12R-A336-31
  ENSG00000000003                         4596
  ENSG00000000005                            3
  ENSG00000000419                          751
  ENSG00000000457                          840
  ENSG00000000460                          205
  ENSG00000000938                          253
  &gt; 
  
  &gt; dim(mat1)
  [1] 56925    11
  &gt; 
  
  &gt; head(mat2)
                  ensembl              symbol
  ENSG00000274572 ENSG00000274572       ZYXP1
  ENSG00000159840 ENSG00000159840         ZYX
  ENSG00000162378 ENSG00000162378      ZYG11B
  ENSG00000232242 ENSG00000232242    ZYG11AP1
  ENSG00000203995 ENSG00000203995      ZYG11A
  ENSG00000070476 ENSG00000070476        ZXDC
  &gt; 
  
  &gt; dim(mat2)
  [1] 36848     2
  &gt; 
  </code></pre>
  
  <p>How I can do that in R?</p>
  
  <p>Thank you</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-20T16:54:08.323Z
Comments.Text: I'm voting to close this question as off-topic because it is not about bioinformatics
Comments.UserDisplayName: llrs
Tags: <r><rna-seq><ensembl>
Title: Matching these matrices in R
ThreadText: # Matching these matrices in R
  
  (Asked by: username_0 on 2019-03-19)
  
  I have two matrices; I want to convert the row names of first matrix to gene symbol from matched ensemble=gene symbol from second matrix
  
  ```
  > head(mat1[,1:2])
                  TCGA-L5-A4OG-11A-12R-A260-31
  ENSG00000000003                         1818
  ENSG00000000005                            0
  ENSG00000000419                         1436
  ENSG00000000457                         1175
  ENSG00000000460                          242
  ENSG00000000938                          536
                  TCGA-IC-A6RE-11A-12R-A336-31
  ENSG00000000003                         4596
  ENSG00000000005                            3
  ENSG00000000419                          751
  ENSG00000000457                          840
  ENSG00000000460                          205
  ENSG00000000938                          253
  > 
  
  > dim(mat1)
  [1] 56925    11
  > 
  
  > head(mat2)
                  ensembl              symbol
  ENSG00000274572 ENSG00000274572       ZYXP1
  ENSG00000159840 ENSG00000159840         ZYX
  ENSG00000162378 ENSG00000162378      ZYG11B
  ENSG00000232242 ENSG00000232242    ZYG11AP1
  ENSG00000203995 ENSG00000203995      ZYG11A
  ENSG00000070476 ENSG00000070476        ZXDC
  > 
  
  > dim(mat2)
  [1] 36848     2
  > 
  
  ```
  
  How I can do that in R?
  
  Thank you
  
  **Tags:** r, rna-seq, ensembl
  
  > **Comments:**
  > **username_1**: I'm voting to close this question as off-topic because it is not about bioinformatics  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2019-03-19. Score: 4 | Accepted answer
  
  Since they share the ensembl\_ID column, you can merge them, then assign the symbol column to the rownames, then delete the symbol column.
  
  something like:
  
  ```
  merged <- merge(mat1, mat2, by = 0) 
  rownames(merge) <- merged[,'symbol'] 
  merged[,symbol] <- NULL
  
  ```
  
  <https://stat.ethz.ch/R-manual/R-devel/library/base/html/merge.html>
  
  
  ---
  
  