9.Handling Errors in R.
9) Write an R program to demonstrate various error messages in R programming.
CODE:
tryCatch( expr={ a=as.integer(5.23) print(a) print("Trying to Execute") }, #specifing error msg error=function(e){ print("There was an error message") }, warning=function(w){ print("There was a warning message") }, finally={ print("'Finally Executed") })
OUTPUT :
[1] 5 [1] "Trying to Execute" [1] "'Finally Executed"