Skip to content
Prev 67276 / 398502 Next

NA in table with integer types

NaN only applies to double values: there is no integer NaN (nor Inf nor 
-Inf).  The difference is clear from
[1] 1    2    3    3    <NA>
Levels: 1 2 3 <NA>
[1] 1    2    3    3    <NA>
Levels: 1 2 3

If you read ?factor it says

  exclude: a vector of values to be excluded when forming the set of
           levels. This should be of the same type as 'x', and will be
           coerced if necessary.

and as.integer(NaN) is integer NA.  So  factor(as.integer(x), exclude=NaN) 
is the same as  factor(as.integer(x), exclude=NA).
On Thu, 7 Apr 2005, Paul Rathouz wrote: