I am running a loop. Warnings sometimes occur, and the lop continues until the end. For each iteration of the loop, I wish to capture and "save" any warnings issued, so that I can tell on which iteration the warnings were issued. I tried this, but it does not work.
mylist <- list(NULL) mylist_warns <- list(NULL) old.warn <- options(warn=1) x <- c(1:5) for (i in 1:2) { assign("last.warning", NULL, envir = baseenv()) mylist[[i]] = x[ (i:1): 5 ] mylist_warns[[i]] = warnings() } mylist mylist_warns ______________________________________________ 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.