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

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

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