Skip to content

Instantly share code, notes, and snippets.

@nilforooshan
Last active March 30, 2019 09:06
Show Gist options
  • Select an option

  • Save nilforooshan/dc7e755d25c85429de04948d1e52cf70 to your computer and use it in GitHub Desktop.

Select an option

Save nilforooshan/dc7e755d25c85429de04948d1e52cf70 to your computer and use it in GitHub Desktop.
R: Remove part of strings after occurrence of a character

Remove part of strings after occurrence of a character

Remove part of strings after “.”

a <- c("NM_020506.1", "NM_020519.1", "NM_001030297.2", "NM_010281.2", "NM_011419.3", "NM_053155.2")
gsub("\\..*","",a)

[1] "NM_020506" "NM_020519" "NM_001030297" "NM_010281" "NM_011419" "NM_053155"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment