[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 


(For security reasons, the file is zipped)

table test

hp	hp1
+	a
-	+

channel = odbcConnectAccess("test.mdb")
ret =  sqlQuery(channel,"select * from test")
# '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

-- Yes, I know I should have reported this earlier, but the problem of
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.



R version 2.7.0 (2008-04-22) 


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