[R] ODD and EVEN numbers

Carl Witthoft carl at witthoft.com
Fri Apr 2 01:14:19 CEST 2010


There you go,  solving his homework again...


 >
 > Hi,
 >
 > anyone here who knows how to determine if an integer is "odd" or
 > "even" in
 > R?
 > Thanks.

  > 2 %% 2 == 0
[1] TRUE
  > 3 %% 2 == 0
[1] FALSE is.even <- function(x){ x %% 2 == 0 }

  > is.even(2)
[1] TRUE



More information about the R-help mailing list