'How to change 1.3445 to 13445, 2.4444 to 24444 , and keep 1.20 not change
How to change 1.3445 to 13445, 2.4444 to 24444 , and keep 1.20 not change. Thanks!
md <- data.frame(value=c('1.3445','1.20','2.4444'))
Solution 1:[1]
I tried below code, it's ok . Here just mark it
md %>% mutate(value_new=if_else(grepl("([1-9]{1,}).([0-9]{4})",value),
str_remove_all(value,'\\.'),value))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | anderwyang |
