Reputation: 2310
I am trying to exclude all ".1"
occurences from my labelexp
data frame.
My input
ID
1 NE001403
2 NE001458.1
3 NE001494.1
4 NE001634.1
5 NE001635.1
6 NE001637.1
I have tried it: labelexp$ID <- gsub(".1", "", labelexp$ID)
, but my output was:
ID
1 NE0403
2 NE0458
3 NE0494
4 NE0634
5 NE0635
6 NE0637
Any ideas? Thank you.
Upvotes: 0
Views: 250
Reputation: 121568
You can also use fixed=TRUE
option:
sub(".1", "","NE001458.1",fixed=TRUE)
"NE001458"
Upvotes: 3
Reputation: 1233
The ".
" is a special character in regular expressions in R - it means any character. You need to put "\\
" in front of it to tell R that you mean it to be the character ".". Thus, try:
labelexp$ID <- gsub("\\.1", "", labelexp$ID)
Does that work for you?
Upvotes: 3