Re: [R] Generate a list of all subsequence of length k from an array

2010-06-22 Thread Henrique Dallazuanna
You could try this: embed(a, k) On Tue, Jun 22, 2010 at 3:35 AM, Ron Shefi wrote: > > Hi, > I would like to generate a list of all subsequence of length k from an > array with length n (k < n). The result should be organized in a matrix. > So the matrix should look like the following whereas e

Re: [R] Generate a list of all subsequence of length k from an array

2010-06-22 Thread David Winsemius
On Jun 22, 2010, at 2:35 AM, Ron Shefi wrote: Hi, I would like to generate a list of all subsequence of length k from an array with length n (k < n). The result should be organized in a matrix. So the matrix should look like the following whereas each row is one of a subsequence of len

[R] Generate a list of all subsequence of length k from an array

2010-06-22 Thread Ron Shefi
Hi, I would like to generate a list of all subsequence of length k from an array with length n (k < n). The result should be organized in a matrix. So the matrix should look like the following whereas each row is one of a subsequence of len k. [a[1:k], a[2:(k+1)] a[3:(k+2)] ... a[(n-k+1):