The objective was to take the logarithm of a given numeric vector that contains a zero and negative numbers. The function is implemented in the following three different ways and their outputs are different:
- stop(): This function generates a customized error message based on the condition supplied. In this example, the condition was to look for any number less than or equal to zero. If there is such a number, then the function will print the error message as, "A negative value exists", and the function will stop producing any other output. Finally, the only error message will be displayed on the R console.
- try(): This function has been used to handle an exception situation. This function tests the expression inside the try() ...