Reputation: 591
I am doing a simple replacement using gsub
> gsub('[^0-9.]','',100000)
[1] "105"
the regexp is to match any non numerical value and replace with ''. Can anyone tell me why I am getting 105
?
Thanks in advance
Upvotes: 1
Views: 94
Reputation: 887028
We can set the options
for scientific notation as it is converting to scientific notation
options(scipen=999)
gsub('[^0-9.]','',100000)
#[1] "100000"
Without setting the options
sub('[^0-9.]','',100000)
#[1] "1+05"
Upvotes: 1