[R] creating possible cominations of a vector's elements

Dimitri Liakhovitski dimitri.liakhovitski at gmail.com
Fri Dec 9 00:02:51 CET 2016


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!

-- 
Dimitri



More information about the R-help mailing list