On 26/02/14 00:56, Enrico Schumann wrote:
<SNIP>
I did not follow your example, neither do I use the deSolve package; but why not pass an environment as an argument? ## some iterative function that takes another fun as argument outer <- function(fun, ...) { for (i in 1:20) fun(...) } ## create an environment ... info <- new.env() info$tt <- 0 ## ... and pass it as an argument myfun <-function(e) { e$tt <- e$tt + 1 cat("Iteration ", e$tt, "\n") } outer(myfun, info) info$tt
Sounds like a good idea. Tried it. Got exactly the same phenomenon as with my idea. The "tdone" variable stays equal to 0 and there is no progress report (as desired) until time gets up to 0.1. Then tdone gets re-set to the value of tt *every* call, so that tt - tdone is always equal to 0 and there are no further progress reports.
I have attached a tar-ball and a zip archive both containing the necessary code to demonstrate the forgoing. Unpack, source all the *.R files and then source "demoScript" to see it happen before your very eyes. :-)
cheers, Rolf Turner
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.