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

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -