I observe this:
> class(x)
[1] "numeric"
> str(x)
num [1:2500] 1 1 1 1 1 1 1 1 1 1 ...
> table(x)
1
2500
> table(x == 1)
FALSE TRUE
299 2201
> all.equal(x, rep(1,length(x)))
[1] TRUE
> dput(x)
c(1, ..... 1) # all ones
how is this possible? I understand that floating point numbers should not be compared using ==
in general, but shouldn't table
be consistent with ==
?
PS. Apparently, table
is consistent with all.equal
and not with ==
because it converts its arguments to factors (i.e., strings) first.
PPS. table(x-1)
shows the non-0 values.