Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
字符串是 And I want to get substrings "11","1.1","282". 谁能告诉我如何在 R 中做到这一点?谢谢!
我相信strsplit(x," +")[[1]]会做到的。(正则表达式" +"表示一个或多个空格;strsplit适用于字符向量,并返回一个列表,其中包含向量中每个元素的拆分版本,因此[[1]]提取第一个(也是唯一的)分量)
strsplit(x," +")[[1]]
" +"
strsplit
[[1]]
> x = "11 1.1 282" > res <- strsplit(x, " +") > res [[1]] [1] "11" "1.1" "282" >