How it works…

The default R function of the form is.x is very powerful and it is easy to understand to check data types and data structure. The use of this type of function is very important to ensure correct input into a function. In this recipe, the newly written function fDescriptive is expected to take a numeric vector as input and do the rest of the calculation. The user might mistakenly provide wrong input and, eventually, the function will provide the wrong output. To avoid receiving a wrong output, you must use the is.x function to check the input.

Inside the body of the function, the use of is.numeric() and is.vector() functions ensures that the input is a numeric vector, and then it calculates the necessary statistics for output. If either of these two checks fail, then the function will not provide any output at all.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset