Skip to content
Prev 279270 / 398503 Next

Vectorization instead of loops problem

On Sun, Dec 4, 2011 at 10:18 AM, Costas Vorlow <costas.vorlow at gmail.com> wrote:
Try this. embed(z, 4) places values 1,2,3,4 of vector z in the first
row, values 2,3,4,5 in the second row and so on so we want the rows of
embed(y, 4) for which embed(x, 4) is 1, i.e we want rows of embed(y,
4) for which embed(x, 4)[,1]==1, except the first column can be
suppressed (-1).
[,1] [,2] [,3]
[1,]   25   50  -40
[2,]  -10   -5   25