Hi,

I am trying to get fread() to read NA without coercing the entire column to 
character, but I am unable to do it.  Please tell me whether I am doing 
something wrong or this is a bug.

# Load two data tables with a column of integers -- one with NA and one without

dt1 <- fread( "a\n2\n4\n8\n5", na.strings=c("?") )
dt2 <- fread( "a\n2\n4\n?\n5", na.strings=c("?") )


# The contents of both are as expected (or so it seems)
dt1
dt2

# The class of the column with NA is character
class( dt1$a )
class( dt2$a )    # Not expecting this to be character

# Even setting colClasses does not help

dt3 <- fread( "a\n2\n4\n?\n5", na.strings=c("?"), colClasses=c(a="integer") )
class( dt3$a )



Thanks for your help.

Regards,
Harish
_______________________________________________
datatable-help mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help

Reply via email to