This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to delete all numbers after dot in a column in R?

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

3 answers

C'mon, just google it: https://stackoverflow.com/questions/10617702/remove-part-of-string-after

gsub("\\.\\d+","",c("ENSG00000223972.5","ENSG00000227232.5","ENSG00000241860.6"))

ENSG00000223972" "ENSG00000227232" "ENSG00000241860"

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

Log in to answer this question.