Skip to content
Prev 177426 / 398506 Next

numbers loop in R

On Fri, Apr 17, 2009 at 12:19 PM, jim holtman <jholtman at gmail.com> wrote:
Here's a solution without the loop.  I think it illustrates the intent
of the algorithm more clearly.

candidates <- t(combn(5,3))
firstdiff <- candidates[,2] - candidates[, 1]
cbind(NaN, candidates[firstdiff == 1, ])

Hadley