Skip to content
Prev 293800 / 398503 Next

substr not by position but by symbol

Hello,


YN wrote
Yes there is.

x <- ".7_-.3_-.2_.9"
strsplit(x, "_")

# To get the numbers, not character vectors
as.numeric(unlist(strsplit(x, "_")))
# Or
sapply(strsplit(x, "_"), as.numeric)

Hope this helps,

Rui Barradas


--
View this message in context: http://r.789695.n4.nabble.com/substr-not-by-position-but-by-symbol-tp4614869p4614889.html
Sent from the R help mailing list archive at Nabble.com.