A recursion like method of avoiding errors in an algorithm that might hit errors due to stochasticity or numerical issues
keepTrying <- function(func, param) tryCatch(func(param), error = function(e) keepTrying(func(param)))