Other Methods for Exception Handling
In this lesson, we mention some other functions that can be useful while handling exceptions.
We'll cover the following
Function to Handle Exceptions
Other methods can be used to handle exceptions in R.
Here is a minimal list of functions that can help programmers in handling errors and warnings in code:
warning(...)
— to generate warningsstop(...)
— to generate errorssuppressWarnings(expression)
— to evaluate the given expression and ignore any warningstryCatch(...)
— we have already studied this in detail here
Let’s have a look at each one of them in detail.
Warning
The function warning()
generates a warning message specified by the programmer. Suppose we are writing a program that divides two numbers however, we know that if a number is divided by , it returns INF
. In such a case it is better to give a warning as this might be an unintentional mistake by the programmer:
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy