[R] identifying odd or even number
Bernardo Rangel Tura
tura at centroin.com.br
Thu Jul 1 19:25:21 CEST 2010
On Thu, 2010-07-01 at 08:40 -0700, Yemi Oyeyemi wrote:
> Hi, I run into problem when writing a syntax, I don't know syntax that will return true or false if an integer is odd or even.
> Thanks
>
> OYEYEMI, Gafar Matanmi
>
> Department of Statistics
>
> University of Ilorin
Hi Yemi!
Your problem is solve wiht "!" and "%%", Look this example
> x <- 1:11
> x
[1] 1 2 3 4 5 6 7 8 9 10 11
> x%%2
[1] 1 0 1 0 1 0 1 0 1 0 1
> !(x%%2)
[1] FALSE TRUE FALSE TRUE FALSE TRUE FALSE TRUE FALSE TRUE FALSE
--
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
Brazil
More information about the R-help
mailing list