[R] help with executing instruction every i-th run of loop
Uwe Ligges
ligges at statistik.uni-dortmund.de
Thu May 17 16:59:30 CEST 2007
Mark W Kimpel wrote:
> I am running a very long loop and would like to save intermediate
> results in case of a system or program crash. Here is the skeleton of
> what my code would be:
>
> for (i in 1:zillion)
> {
> results[[i]]<-do.something.function()
> if (logical.test(i)) {save(results, "results.tmp")}
> }
>
> logical.test would test to see if i/1000 has no remainder. What R
> function would test that?
!(i %% 1000)
Uwe Ligges
> Is there an even better way to address my need?
>
> Thanks,
> Mark
More information about the R-help
mailing list