[R] "na.strings" and the like; suspending interpretation of "NA"
Jan Theodore Galkowski
bayesianlogic at acm.org
Wed Aug 5 00:16:19 CEST 2009
The magic I was looking for is to pass "as.is=TRUE" to "sqlQuery" of
RODBC.
The reference to "read.table" is a little oblique, but with that, all
works fine.
An education!
:-)
Thanks much,
Jan
On Tue, 04 Aug 2009 09:05:05 +0200, "Peter Dalgaard"
<p.dalgaard at biostat.ku.dk> said:
> Jan Theodore Galkowski wrote:
> > Can someone point me to the proper place in the documentation or on the
> > Wiki where I can learn how to get R to stop interpreting the string "NA"
> > as something special? I have a table in a database which contains
> > (among other things) country codes and continent codes. The standard
> > set of two-letter codes includes "NA" to denote "North America". I
> > learned of the "na.strings" parameter for RODBC's "sqlQuery", being able
> > to shut down this interpretation when data is read in.
> >
> > However, in the program which uses this data, I (must) have some other
> > instance where the "NA" gets spontaneously"interpreted as "not
> > available", shows up in vectors and lists as "<NA>", and breaks
> > function. I temporarily solved the problem by defining all instances of
> > "NA" in the database as "NAC". It still would be good to know a
> > generaly solution. I've seen something mentioned in conjunction with
> > "options", but I'm not sure what that is about.
>
> The general paradigm is that this shouldn't happen... Back in the old
> days, R had no such thing as character NA, and users had to sort out the
> North America, noradrenaline, Neil Armstrong, etc., issues for
> themselves. Nowadays we do have calculus that preserves "NA" as distinct
> from <NA>; so if one is converted to the other, it could signify a bug.
>
> It could also be due to particularly silly code on your behalf, but in
> either case we need to see the effect narrowed down to a reproducible
> stretch of code.
[snip]
More information about the R-help
mailing list