Skip to content
Prev 26453 / 398502 Next

disabling NA token as na.string in read.table

Vadim Ogranovich <vograno at arbitrade.com> writes:
Hmm, this looks like a bit of a bug. read.table() ends up calling
type.convert() with its default "NA" na.string. Now, if "NA" was in
the na.string for read.table(), scan() would already have turned it
into <NA> at that point, so I suspect you might have preferred
na.strings=character(0), but that has the side effect of turning the
real NA into a factor level:
[1] <NA> <NA> foo
Levels: foo
[1] <NA> NA   foo
Levels: NA foo NA
structure(c(3, 1, 2), .Label = c("NA", "foo", NA), class = "factor")

I.e. it looks like the internals of type.convert needs some fixing up.