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

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


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 is"
"this is my"
"this is my vector"
"is my"
"is my vector"
"my vector"

Thanks a lot!


More information about the R-help mailing list