R/safe_fn.R

safe_fn <- function(fn, ..., i = 1, pb = NULL){
  res <- purrr::safely(fn, otherwise = NA)(...)
  if(!is.null(pb))
    utils::setTxtProgressBar(pb, i)

  if(any(is.na(res$result)))
    print(paste0('fn error on sample ', i, ', error messages: ', res$error$message))

  res$result
}

Try the suropt package in your browser

Any scripts or data that you put into this service are public.

suropt documentation built on May 2, 2019, 6:02 a.m.