Hi All,

i have n numbers(lets say n=5) and i want to create all possible combination of these five numbers keeping in mind that the combination must be in sequential order.For instance,

let’s say the 5 numbers are 1,2,3,4,5

So, i want to achieve combinations like:

1,2,3,4,5

12,3,4,5

123,4,5

1234,5

12,3,4,5

12,34,5

12,3,45

12,345

1,2,345

…

…

and so on.

The important point to keep in mind is that , none of the combination breaks the order.For example,

i cannot have combinations like,

13,2,45

145,32

132,54

1,43,25

…

…

and so on.

I am trying to do it in R.

Please help me in suggesting some approach in order to solve this issue.

I hope, the problem statement is clear.

If not, please let me know, i’ll provide more elaborative explanation.

Thanks a lot!