Thank you for the code Tiago211287. But at the end my file (my_ids.version) is returned empty. I had replaced the line
my_ids <- data.frame(ensembl_gene_id_version=c("ENSG00000272379.1","ENSG00000175600.11","ENSG00000224017.1","ENSG00000112137.12"))
with
test <- read.table("MetaXcanOutput-BiomartInput.txt")
my_ids <- data.frame(ensembl_gene_id_version=c(test$v1))
where MetaXcanOutput-BiomartInput.txt is the file containing almost 6000 gene ids along with the version number. Moreover, the data frame object "my_ids" contains two identical column as follows.
ensembl_gene_id_version ensembl_gene_id
6544 6544
4060 4060
5340 5340
I am pretty new to data science and R. But according to my understanding, in the last code my_ids.version <- merge(my_ids, t2g, by= 'ensembl_gene_id') it cannot find the proper ensembl_gene_id due to which my_ids.version is empty. Am I right? Can you further suggest?