I am using R and this is how my data looks like,
a <- data.frame(id=c(1,2,2,2,3),icd9=c("0781","00840","8660","7100","25011"))
I want to place a dot after the 3rd digit in both four digits and five-digit numbers in second column. I am using gsub in R but not getting desired output. My desired data frame is:
id icd9
1 078.1
2 008.40
2 866.0
2 710.0
3 250.11
I am trying
gsub('([0-9])', '\\1\\2\\3.\\4', a$icd9)
But I am getting
[1] "0.7.8.1." "0.0.8.4.0." "8.6.6.0." "7.1.0.0." "2.5.0.1.1."
Thanks, guys in advance :)