0
我有一個字符串'x'的向量基於一個更長的字符串 'mystring'(x的實際長度未知)。R:從左到右創建一個向量的元素組合
mystring <- "this is my vector"
x <- strsplit(mystring, " ")[[1]]
我要尋找一個包含以下字符串創建對象的一個優雅的方式(例如列表) :
string1
string1 + string2
string1 + string2 + string3
string1 + string2 + string3 + string 4
string2
string2 + string3
etc.:
"this"
"this is"
"this is my"
"this is my vector"
"is"
"is my"
"is my vector"
"my"
"my vector"
"vector"
非常感謝!