Getting ready

Unlike the ifelse function, if…else works for conditioning on a scalar-valued input and output. The ifelse function takes the input as a vector and produces a vector output with the same length as that of the input. However, if…else takes only a scalar-valued input and it only generates TRUE or FALSE and then executes the body of task that you define. Let’s assume you have a number stored in the variable a and you want to test whether the given number is odd or even. In this recipe, you will write R code to test the a variable. The value of a could be any arbitrary integer number.

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

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