Create adjacent combinations of the elements of a vector, varying the length with each iteration.
adjCombos(invec)
invec | The input vector |
---|
A list
of vectors
http://stackoverflow.com/a/20157957/1270695
Ananda Mahto
adjCombos(letters[1:5])#> [[1]] #> [1] "a" "b" #> #> [[2]] #> [1] "b" "c" #> #> [[3]] #> [1] "c" "d" #> #> [[4]] #> [1] "d" "e" #> #> [[5]] #> [1] "a" "b" "c" #> #> [[6]] #> [1] "b" "c" "d" #> #> [[7]] #> [1] "c" "d" "e" #> #> [[8]] #> [1] "a" "b" "c" "d" #> #> [[9]] #> [1] "b" "c" "d" "e" #>