R/internal.R

Defines functions safely as_conditional_tibble

as_conditional_tibble <- function(x) {
  if(requireNamespace("tibble", quietly = TRUE))
    x <- tibble::as_tibble(x)
  x
}

safely <- function(.f) {
  function(...) {
    x <- try(.f(...), silent = TRUE)
    if(inherits(x, "try-error")) return(list(result = NULL, error = as.character(x)))
    list(result = x, error = NULL)
  }
}

Try the ssdtools package in your browser

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

ssdtools documentation built on May 2, 2019, 5:45 a.m.