Skip to content
Prev 365963 / 398502 Next

creating possible cominations of a vector's elements

Hello!

I have a vector of strings 'x' that was based on a longer string
'mystring' (the actual length of x is unknown).

mystring <- "this is my vector"
x <- strsplit(mystr, " ")[[1]]

I am looking for an elegant way of creating an object (e.g., a list)
that contains the following strings:

"this"
"this is"
"this is my"
"this is my vector"
"is"
"is my"
"is my vector"
"my"
"my vector"
"vector"

Thanks a lot!