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)
How to extract substrings from this string?
سؤال
The string is And I want to get substrings "11","1.1","282". Can anyone show me how to do this in R? Thanks!
لا يوجد حل صحيح
نصائح أخرى
> x = "11 1.1 282"
> res <- strsplit(x, " +")
> res
[[1]]
[1] "11" "1.1" "282"
>
لا تنتمي إلى StackOverflow