[R] + and - in RODBC : no longer considered factors
Dieter Menne
dieter.menne at menne-biomed.de
Wed Apr 30 11:57:22 CEST 2008
I have a large Sweave report that reads data from a database file. Some of
the columns are 1-character strings containing only +, - or NA. An example
for such a table is shown below, and can be downloaded for easier testing
from
http://www.menne-biomed.de/uni/test.zip
(For security reasons, the file is zipped)
table test
hp hp1
+ a
- +
library(RODBC)
channel = odbcConnectAccess("test.mdb")
ret = sqlQuery(channel,"select * from test")
odbcClose(channel)
str(ret)
# 'data.frame': 2 obs. of 2 variables:
# $ hp : num 0 0
# $ hp1: Factor w/ 2 levels "+","a": 2 1
Note that the column hp with "+" and "-" only is read as numeric 0, but
when there is only other character such as in hp1, the conversion occurs.
In R 2.6.2 (or was it an earlier version of RODBC?), column hp was treated
as factor.
Is this a new feature I have to live with, or an ... ahem ... issue? I know
that with as.is I can get around this, but it need a lot of explicit
programming for the columns I don't want to be as.issed
Disclaimer:
-- Yes, I know I should have reported this earlier, but the problem of
having
to re-create the report came up today.
-- Yes, I should have reported this on the windows/devel r-help or directly
to the author (of RODBC; or base?), so I feel guilty in advance that this is
the wrong list.
-- Yes, I have read the NEWS, and could not find something related.
-- Yes, I cannot rule out this is a user error.
Dieter
---------------------------
R version 2.7.0 (2008-04-22)
i386-pc-mingw32
locale:
LC_COLLATE=German_Germany.1252;LC_CTYPE=German_Germany.1252;LC_MONETARY=Germ
an_Germany.1252;LC_NUMERIC=C;LC_TIME=German_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] RODBC_1.2-3
>
>
More information about the R-help
mailing list