Analytics Vidhya
Published in

Analytics Vidhya

Error Handling in R

What is an Exception?

Exception Handling

Exception Handling Constructs in R

  1. try
  2. tryCatch

Using try

v<-list(1,2,4,'0',5)
for (i in v) {
try(print(5/i))
}

Using tryCatch

v<-list(1,2,4,'0',5)
for (i in v) {
tryCatch(print(5/i),error=function(e){
print("Non conformabale arguments")
})
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store