October 2017
Beginner to intermediate
236 pages
7h 38m
English
To check whether the value of the a variable is an even or odd number, the R code is as follows:
a <- 9 if(a %% 2==0){ print("This is an even number") } else { print("This is an odd number") }
To check whether a given number is an odd or even, first, you must calculate the remainder after dividing the number by 2. Then, if the remainder is a 0, the number is an even number, otherwise it is an odd number.