Question

The string is enter image description here And I want to get substrings "11","1.1","282". Can anyone show me how to do this in R? Thanks!

No correct solution

OTHER TIPS

I believe strsplit(x," +")[[1]] will do it. (the regular expression " +" denotes one or more spaces; strsplit applies to character vectors, and returns a list with the splitted version of each element in the vector, so [[1]] extracts the first (and only) component)

> x = "11  1.1     282"
> res <- strsplit(x, " +")
> res
[[1]]
[1] "11"  "1.1" "282"

> 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top