Skip to content
Prev 171671 / 398503 Next

Have a function like the "_n_" in R ? (Automatic count function )

And for completeness here's a function that returns the next integer
on each call.

n <- (function(){
  i <- 0
  function() {
    i <<- i + 1
    i
  }
})()
[1] 1
[1] 2
[1] 3
[1] 4
[1] 5
[1] 6


;)

Hadley
On Wed, Feb 25, 2009 at 8:27 AM, David Winsemius <dwinsemius at comcast.net> wrote: