【发布时间】:2015-11-11 22:26:31
【问题描述】:
根据拆分条件 (' ') 是在字符串的开头还是结尾,它会在输出列表中显示为一个项目。
#strsplit("This is a string ")
strsplit("This is a string ", ' ')
#[[1]]
#[1] "This" "is" "a" "string"
#strsplit(" And this is a string", ' ')
strsplit(" And this is a string", ' ')
#[[1]]
#[1] "" "And" "this" "is" "a" "string"
有没有办法更改此代码,以便空间显示为两个列表的项目?
预期输出:
#strsplit("This is a string ")
strsplit("This is a string ", ' ')
#[[1]]
#[1] "This" "is" "a" "string" ""
#strsplit(" And this is a string", ' ')
strsplit(" And this is a string", ' ')
#[[1]]
#[1] "" "And" "this" "is" "a" "string"
【问题讨论】:
-
请注意,这是在“详细信息”部分中
?strsplit记录的行为。