Dear RStudio Community,
In its simplest form, my question is this. I have a data.frame (res) which has a series of row names. I want to replace these row names with a different string, which is the 2nd column of another variable (G_list). Sometimes this replacement string is empty. In particular, the first column of G_list has string entries which match with rownames(res). However, many of the 2nd column of G_list is empty.
For example:
> rownames(res)[1]
[1] "ENSG00000223972"
Which I want to replace with the string in the column hgnc_symbol (namely "DDX11L1"). This is because G_list[209,] gives:
> G_list[209,]
ensembl_gene_id hgnc_symbol ensembl_gene_id_version
ENSG00000223972 ENSG00000223972 DDX11L1 ENSG00000223972.8
So I am matching based on the row names of G_list and res, and replacing with a string in G_list$hgnc_symbol.
However, for some row names in res, I have the following:
rownames(res)[100]
[1] "ENSG00000117600"
And I want to find the string to replace this with in G_list, which occurs at row 389:
> G_list[389,]
ensembl_gene_id hgnc_symbol ensembl_gene_id_version
ENSG00000117600 ENSG00000117600 ENSG00000117600.8
So I need to replace the row name with an empty row name. (Or I can leave the row name as "ENSG00000117600" if the replacement is "" [blank].
How do I do this?
Thanks for your help!
Lottie
