Re: [R] The elegant way to test if a number is a whole number

2011-09-09 Thread William Dunlap
t: Friday, September 09, 2011 1:41 AM > To: Marc Schwartz > Cc: r-help; Alexander Engelhardt > Subject: Re: [R] The elegant way to test if a number is a whole number ... [ many lines elided ] ... > >>>>> is.whole <- function(x) > >>>>> is.numeri

Re: [R] The elegant way to test if a number is a whole number

2011-09-09 Thread Martin Maechler
> Marc Schwartz > on Thu, 8 Sep 2011 15:41:26 -0500 writes: > On Sep 8, 2011, at 3:09 PM, David Winsemius wrote: >> >> On Sep 8, 2011, at 3:54 PM, Marc Schwartz wrote: >> >>> >>> On Sep 8, 2011, at 2:42 PM, David Winsemius wrote: >>>

Re: [R] The elegant way to test if a number is a whole number

2011-09-08 Thread David Winsemius
On Sep 8, 2011, at 4:41 PM, Marc Schwartz wrote: On Sep 8, 2011, at 3:09 PM, David Winsemius wrote: On Sep 8, 2011, at 3:54 PM, Marc Schwartz wrote: On Sep 8, 2011, at 2:42 PM, David Winsemius wrote: On Sep 8, 2011, at 3:35 PM, Alexander Engelhardt wrote: Am 08.09.2011 20:48, schrie

Re: [R] The elegant way to test if a number is a whole number

2011-09-08 Thread Marc Schwartz
On Sep 8, 2011, at 3:09 PM, David Winsemius wrote: > > On Sep 8, 2011, at 3:54 PM, Marc Schwartz wrote: > >> >> On Sep 8, 2011, at 2:42 PM, David Winsemius wrote: >> >>> >>> On Sep 8, 2011, at 3:35 PM, Alexander Engelhardt wrote: >>> Am 08.09.2011 20:48, schrieb Marc Schwartz: > Th

Re: [R] The elegant way to test if a number is a whole number

2011-09-08 Thread David Winsemius
On Sep 8, 2011, at 3:54 PM, Marc Schwartz wrote: On Sep 8, 2011, at 2:42 PM, David Winsemius wrote: On Sep 8, 2011, at 3:35 PM, Alexander Engelhardt wrote: Am 08.09.2011 20:48, schrieb Marc Schwartz: There was a post from Martin Maechler some years ago and I had to search a bit to find

Re: [R] The elegant way to test if a number is a whole number

2011-09-08 Thread Marc Schwartz
On Sep 8, 2011, at 2:42 PM, David Winsemius wrote: > > On Sep 8, 2011, at 3:35 PM, Alexander Engelhardt wrote: > >> Am 08.09.2011 20:48, schrieb Marc Schwartz: >> > There was a post from Martin Maechler some years ago and I had to search a >> > bit to find it. For these sorts of issues, I typi

Re: [R] The elegant way to test if a number is a whole number

2011-09-08 Thread David Winsemius
On Sep 8, 2011, at 3:35 PM, Alexander Engelhardt wrote: Am 08.09.2011 20:48, schrieb Marc Schwartz: > There was a post from Martin Maechler some years ago and I had to search a bit to find it. For these sorts of issues, I typically trust his judgement. > > The post is here: > >https://

Re: [R] The elegant way to test if a number is a whole number

2011-09-08 Thread Alexander Engelhardt
Am 08.09.2011 20:48, schrieb Marc Schwartz: > There was a post from Martin Maechler some years ago and I had to search a bit to find it. For these sorts of issues, I typically trust his judgement. > > The post is here: > >https://stat.ethz.ch/pipermail/r-help/2003-April/032471.html > > His

Re: [R] The elegant way to test if a number is a whole number

2011-09-08 Thread Marc Schwartz
There was a post from Martin Maechler some years ago and I had to search a bit to find it. For these sorts of issues, I typically trust his judgement. The post is here: https://stat.ethz.ch/pipermail/r-help/2003-April/032471.html His solution also handles complex numbers. HTH, Marc Schwartz

Re: [R] The elegant way to test if a number is a whole number

2011-09-08 Thread Bert Gunter
Have a close look at ?storage.mode and ?typeof. The problem here, as usual and as you seem to allude is: define "integer" . Mathematically, there is an unequivocal definition, but not so in finite precision arithmetic. Are you referring to the machine representation (typeof()), or the approximate

Re: [R] The elegant way to test if a number is a whole number

2011-09-08 Thread Jason Morgan
Hello Alex, Have you tried the modulus operator? > 2 %% 1 [1] 0 > 2.1 %% 1 [1] 0.1 ~Jason On 2011.09.08 20:27:14, Alexander Engelhardt wrote: > Hi, > > x <- 0.2*5 > is.integer(x) > > gives me FALSE because R stores it as a float number, right? > Is there an elegant way to work aroun