Create adjacent combinations of the elements of a vector, varying the length with each iteration.

adjCombos(invec)

Arguments

invec

The input vector

Value

A list of vectors

References

http://stackoverflow.com/a/20157957/1270695

Author

Ananda Mahto

Examples

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" #>