I have vector of strings containing numbers. Within these strings, I would like to remove all access zeros behind the decimal separator. So I tried mutate_all(funs(str_replace(., ".00", "")))
.
This works for the first number in my vector:
v <- c("bla 500.00", "bla 1.20", "bla 1.10", "bla 2.34")
.
For the rest I would not like to hard code mutate_all(funs(str_replace(., ".10", ".1")))%>%mutate_all(funs(str_replace(., ".20", ".2")))%>% ...
, but use some kind of smart regex, which automatically does the job. So, removing every zero which is behind ".non-zero-integer" (dot non-zero-integer), while keeping the ".non-zero-integer" the same.