Quantcast

ODD and EVEN numbers

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

ODD and EVEN numbers

TJ-2
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ODD and EVEN numbers

Erik Iverson-3
See %% under ?Arithmetic

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

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ODD and EVEN numbers

David Winsemius
In reply to this post by TJ-2

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

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ODD and EVEN numbers

Stephan Kolassa
In reply to this post by TJ-2
(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

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ODD and EVEN numbers

TJ-2
This post was updated on .
In reply to this post by TJ-2
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ODD and EVEN numbers

Carl Witthoft
In reply to this post by TJ-2
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

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ODD and EVEN numbers

TJ-2
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ODD and EVEN numbers

Detlef Steuer
In reply to this post by TJ-2

Just to give you a hint for the future:

If you ask google for "odd, even, R" you get a messages from 2003 as second match:

-------------------------------
Dave Caccace wrote:
> Hi,
> I'm trying to create a function, jim(p) which varies
> depending on whether the value of p is odd or even. I
> was trying to use th eIf function, but i cant work out
> a formula to work out if p is odd or even.
> Thanks,
> Dave

if(p %% 2) "odd" else "even"

Uwe Ligges
------------------------------
(Hi Uwe!)

My guess is, using so much capitals in your e-mail has turned away about 1000
helpful souls from your future posts.

May be reading the posting guide and a one minute try to solve the
problem by yourself googling would be appropriate?
Think for a moment: Google would have given an answer (the answer!) in 1
minute. You wrote an e-mail to quite a few thousands of subscribers.
That needed more than a minute on your side. And how many hours of
reading time took it off of your readers?

Seasonal greetings
Detlef



On Thu, 01 Apr 2010 17:27:01 -0700
[hidden email] wrote:

> 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.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Loading...