[R] how to stop without error message?

hadley wickham h.wickham at gmail.com
Tue Nov 11 04:19:55 CET 2008


>
> I should have been clearer, sorry-- I'm trying to exit from an "inner" function which might be several levels deep, returning straight to the R prompt. To be specific, I'm trying to clean up the "No Error in..." message in my 'debug' package-- the "No " prefix being my original workaround to avoid an unnecessarily alarming message.

Ah, ok.  How about signalling custom condition then?

f <- function() {
  print("a")
  g()
  print("d")
}

g <- function() {
  print("b")
  error <- simpleError("")
  class(error) <- c("myerror", class(error))
  signalCondition(error)
  print("c")
}

f()
tryCatch(f(), myerror = function(...) print("stopped!"))

Hadley


-- 
http://had.co.nz/



More information about the R-help mailing list