Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- test.fun <- function(environment){
- err <- tryCatch({
- with(environment, {
- if (abs(loglik.new - loglik.old) / (1 + abs(loglik.old)) > convergence)
- print(1)
- })
- }, error = function(e) e)
- return(err$message)
- }
- env1 <- new.env()
- env1$loglik.new <- NA
- env1$loglik.old <- 1
- env1$convergence <- 1e-6
- test.fun(env1)
- # [1] "missing value where TRUE/FALSE needed"
- env2 <- new.env()
- env2$loglik.old <- 1
- env2$convergence <- 1e-6
- test.fun(env2)
- # [1] "object 'loglik.new' not found"
Add Comment
Please, Sign In to add comment