[R] need help with withRestarts ?
ce
zadig_1 at excite.com
Sat Dec 6 23:53:27 CET 2014
Dear all,
Let's say I have this script , below. tryCatch indeed catches the error but exists, I want function to continue and stay in the loop. I found very examples of withRestarts on internet to figure it out. Could you help me how to do it ?
myfunc <- function()
{
while(1)
{
x <- runif(1)
if ( x > 0.3 ) a <- x/2 else a <- x/"b"
print(a)
Sys.sleep(1)
}
}
tryCatch({ myfunc() },
warning = function(w) { print("warning") },
error = function(e) { print("error") },
finally = { print("end") }
)
More information about the R-help
mailing list