0

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)

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
Sophia
  • 99
  • 5

1 Answers1

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