regex - R regular expression replace :75% -> 0.75 -


surely naive question i'm in r , have expression

v <- "gastrula:75%" 

that want replace "gastrula0.75"

i tried things :

v <- sub("\\.(\\d+)%","0.\\1",v) v <- sub("[:punct:](\\d)\\1+[:punct:]","0.\\1",v) 

but didn't find worked.

here's possibility:

v <- "gastrula:75%" str <- unlist(strsplit(v,":")) paste0(str[1], as.numeric(gsub("%","",str[2]))/100) 

Comments

Popular posts from this blog

apache - setting document root in antoher partition on ubuntu -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -

Process 'command 'F:\android-sdk\build-tools\21.1.2\aapt.exe'' finished with non-zero exit value 1 -