Skip to content
Prev 286220 / 398502 Next

NaN from function

On Thu, Feb 23, 2012 at 04:40:07PM -0000, Ted Harding wrote:
[...]
Hi.

The condition length(table(x)) > 1 may also be written as
lentgh(unique(x)) > 1. These two conditions are usually
equivalent, but not always due to the rounding to 15 digits
performed in table(). For example

  x <- 1 + (0:10)*2^-52
  length(table(x))  # [1] 1
  length(unique(x)) # [1] 11
  sd(x)             # [1] 7.364386e-16
  diff(x)           # [1] 2.220446e-16 2.220446e-16 2.220446e-16 ...

Petr Savicky.