How to delete all numbers after dot in a column in R?
3
0
Entering edit mode
2.3 years ago
Amr ▴ 180

How to delete all strings after dot in a column in R?

For example If I have a column in R has Ensemble Gene Ids like:

ENSG00000223972.5

ENSG00000227232.5

ENSG00000241860.6

How to make it

ENSG00000223972

ENSG00000227232

ENSG00000241860

Thanks

string R Gene ensemble • 1.9k views
ADD COMMENT
6
Entering edit mode
ADD COMMENT
0
Entering edit mode
2.3 years ago
gsub("\\.\\d+","",c("ENSG00000223972.5","ENSG00000227232.5","ENSG00000241860.6"))

ENSG00000223972" "ENSG00000227232" "ENSG00000241860"
ADD COMMENT
0
Entering edit mode
2.3 years ago
Trivas ★ 1.8k

Here's a tidyr way of doing it, where gene is the column name containing your Ensembl IDs: str_extract(gene, "^([^.]+)")

ADD COMMENT

Login before adding your answer.

Traffic: 2447 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6