Questions #Tagged [r-programming]

Questions: 1

How to convert every % value with decimal in R programming?

We can use auxiliary function and mutate_if to achieve this output. Below is the code snippet:<br> <pre><xmp>is.percentage <- function(x) any(grepl("%$", x)) df1 %>% mutate_if(is.percentage, ~as.numeric(sub("%", "", .))/100)</xmp></pre>

 

#r-programming     #function