I am sure this is simple, but I am not finding an answer, so anything helps! I have a variable for ICD code and the decimals are still in the codes. Using R, how do I remove the decimal so that this observation, 'O99.013', would look like this 'O99013' ? (NOTE: There are letters in the ICD codes, so it is not being treated like an integer)
Asked
Active
Viewed 157 times
0
-
1thanks @camille, I looked for the duplicates but couldn't find them – Ben Bolker Jan 18 '22 at 18:09
1 Answers
1
Removing dots is a little bit tricky because they're treated as special characters in regular expressions.
gsub("\\.", "", mydata$ICD_code)
or
gsub(".", "", mydata$ICD_code, fixed = TRUE)
or
gsub("[.]", "", mydata$ICD_code)
(.
is not treated as a special character when it's included in a set of characters with []
)
or the equivalent with stringr::str_remove()

Ben Bolker
- 211,554
- 25
- 370
- 453