Skip to content
Prev 318381 / 398503 Next

Count function calls

This is where <<- is helpful:
   > N <- 0 ; trace(solve, quote(N <<- N + 1), print=FALSE)
   Tracing function "solve" in package "base"
   [1] "solve"
   > lapply(3:0, function(i)solve(diag(i,3), 1:3))
   Error in solve.default(diag(i, 3), 1:3) : 
     Lapack routine dgesv: system is exactly singular: U[1,1] = 0
   > N
   [1] 4

You can also set
   options(error=recover)
to look at the state of things when the error occurs.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com