Skip to content

Instantly share code, notes, and snippets.

@jlehtoma
Created December 7, 2015 13:32
Show Gist options
  • Save jlehtoma/f1b56f64cb3fa96f2876 to your computer and use it in GitHub Desktop.
Save jlehtoma/f1b56f64cb3fa96f2876 to your computer and use it in GitHub Desktop.
Print warnings as they happen with a for-loop in R
war <- function(x) {
suppressWarnings(w <- warning("There's a problem with: ", x))
message(w)
return(x)
}
for (i in 1:5) {
Sys.sleep(1)
war(i)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment