[R] sqlQuery of variable of type varchar - confusion with "."

Søren Højsgaard Soren.Hojsgaard at agrsci.dk
Thu Nov 29 13:03:12 CET 2007


Dear list,
I have a rather large dataset in SAS which I export to a SQLite database for subsequent use in R.
 
One of the columns is
cowidp	
1881501224.2	
1881501224.2	
 
and the column is stored as a character in SAS. It becomes a varchar in the database (it should be - it is an identifier; not a number). Reading this into R gives
      cowidp
1 1881501224
2 1881501224
....
- i.e. the ".2" is stripped off - and it becomes a numeric variable
 
However, if I store replace "." with "_" in my SAS data then the column in my database is
 
cowidp	
1881501224_2	
1881501224_2	
 
Reading into R gives
        cowidp
1 1881501224_2
2 1881501224_2

as it "should be" - it becomes a factor
 
Is the fact that the "."-part does not seem to work a bug in sqlQuery (or somewhere else) or is it the intention that things containing a "." are converted into numeric values if possible?
 
Regards
Søren
 
 
 
 
 
 
 
 



More information about the R-help mailing list