Mercurial > repos > eschen42 > w4mcorcov
view w4mcorcov_util.R @ 6:7bd523ca1f9a draft
planemo upload for repository https://github.com/HegemanLab/w4mcorcov_galaxy_wrapper/tree/master commit cafda5095a79ce2376325b57337302f95137195d
author | eschen42 |
---|---|
date | Wed, 18 Jul 2018 12:35:55 -0400 |
parents | 50f60f94c034 |
children | ddcc33ff3205 |
line wrap: on
line source
# tryCatchFunc wraps an expression that produces a value if it does not stop: # tryCatchFunc produces a list # On success of expr(), tryCatchFunc produces # list(success TRUE, value = expr(), msg = "") # On failure of expr(), tryCatchFunc produces # list(success = FALSE, value = NA, msg = "the error message") tryCatchFunc <- function(expr) { # format error for logging format_error <- function(e) { paste(c("Error { message:", e$message, ", call:", e$call, "}"), collapse = " ") } retval <- NULL tryCatch( expr = { retval <- ( list( success = TRUE, value = eval(expr = expr), msg = "" ) ) } , error = function(e) { retval <<- list( success = FALSE, value = NA, msg = format_error(e) ) } ) return (retval) } # # pseudo-inverse - computational inverse of non-square matrix a # p.i <- function(a) { # solve(t(a) %*% a) %*% t(a) # }