Skip to content
Prev 151840 / 398498 Next

dput vs unclass to see what a factor really is composed of

On 31/07/2008 5:21 PM, Jacob Wegelin wrote:
Those are integer constants.  Compare:

 > typeof(1)
[1] "double"
 > typeof(1L)
[1] "integer"

A digit 1 is taken to be "double" (or "numeric"), i.e. a 64 bit double 
precision floating point.  A constant 1L is "integer", i.e. a 32 bit 
signed integer.  Factors only contain integer values, so we use integers 
to store them, and dput() writes them out that way so that they wouldn't 
get converted to floating point when you read them in.

Duncan Murdoch