October 2017
Beginner to intermediate
236 pages
7h 38m
English
In the first step, you should create the source variable to apply the conditional operation and then calculate the cut-off median for this recipe. Once you have the source variable and the cut-off value, you can pass the conditional operator > inside the ifelse function. The ifelse function takes the source variable as input and a cut-off with conditional operator. In this recipe, the conditional operator is a greater than operator >. If the value of the variable x is greater than the median of x, then the new variable newX will get a value 1; otherwise, it will get 0. The ifelse function works in a vector of input, and it does not require any repetition or loop. Only the single line of code can perform the operation for the ...