postgresql - convert character string into R integer vector -
i receive character string "{1,0,0,0,0,0}" created textual representation of vector (integer[]) postgresql , have cast r integer/numeric vector. there efficient way convert v r representation of vector? in advance.
v [1] "{1,0,0,0,0,0}"
class(v) [1] "character"
mode(v) [1] "character"
typeof(v) [1] "character"
if positive integer then:
as.integer(unlist(strsplit("{1,0,0,0,0}", "\\d+"))[-1])
if negative possibility:
as.integer(unlist(strsplit("{1,-3,0,0,0}", "[,{}]"))[-1])
Comments
Post a Comment