Hi, anyone here who knows how to determine if an integer is "odd" or "even" in R? Thanks. tj -- View this message in context: http://n4.nabble.com/ODD-and-EVEN-numbers-tp1747032p1747032.html Sent from the R help mailing list archive at Nabble.com.
See %% under ?Arithmetic tj wrote:> Hi, > > anyone here who knows how to determine if an integer is "odd" or "even" in > R? > Thanks. > > > tj
On Mar 31, 2010, at 12:43 PM, tj wrote:> > 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 -- David Winsemius, MD West Hartford, CT
(foo %% 2) == 0 See ?"%%" HTH Stephan tj schrieb:> Hi, > > anyone here who knows how to determine if an integer is "odd" or "even" in > R? > Thanks. > > > tj
Thank you guys for responding to my question. Have a great day!:-) -- View this message in context: http://n4.nabble.com/ODD-and-EVEN-numbers-tp1747032p1747411.html Sent from the R help mailing list archive at Nabble.com.
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
Excuse me Carl Withoft! For your information, this is not my homework. I'm just helping my friend in "a part" of her R code. And everytime I ask a question here, it's just a "SMALL PART" of the 2-pages-program that I am doing. And for your information, the answers that I get, I still think on how to make use of them. It does not mean that when I get answers, I use them immediately without thinking! And you have no right to tell me that coz I don't remember you answering any of my questions. IF YOU DON'T KNOW THE ANSWERS TO MY QUESTIONS, just keep quiet, and let the smart guys share their thoughts.