I have a large data.frame in R with thousands of rows and 4 columns. For example:
Chromosome Start End Count
1 NC_031985.1 16255093 16255094 1
2 NC_031972.1 11505205 11505206 1
3 NC_031971.1 24441227 24441228 1
4 NC_031977.1 29030540 29030541 1
5 NC_031969.1 595867 595868 1
6 NC_031986.1 40147812 40147813 1
I have this data.frame with the chromosome names accordingly
LG1 NC_031965.1
LG2 NC_031966.1
LG3a NC_031967.1
LG3b NC_031968.1
LG4 NC_031969.1
LG5 NC_031970.1
LG6 NC_031971.1
LG7 NC_031972.1
LG8 NC_031973.1
LG9 NC_031974.1
LG10 NC_031975.1
LG11 NC_031976.1
LG12 NC_031977.1
LG13 NC_031978.1
LG14 NC_031979.1
LG15 NC_031980.1
LG16 NC_031987.1
LG17 NC_031981.1
LG18 NC_031982.1
LG19 NC_031983.1
LG20 NC_031984.1
LG22 NC_031985.1
LG23 NC_031986.1
I want to replace all row names of the large matrix with the chromosome names as listed above and get:
Chromosome Start End Count
1 LG22 16255093 16255094 1
2 LG7 11505205 11505206 1
3 LG6 24441227 24441228 1
4 LG12 29030540 29030541 1
5 LG4 595867 595868 1
6 LG23 40147812 40147813 1
Does anybody know which is the less painful way to do this? It might be easy (or not) but my experience in R is limited.
Many thanks!