[datatable-help] fread() coercing to character when seeing NA
Harish
harishv_99 at yahoo.com
Sun Sep 29 19:03:24 CEST 2013
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20130929/0a31d139/attachment-0001.html>
More information about the datatable-help
mailing list