vendredi 24 avril 2015

In R: dbGetQuery() coerces a string to a numeric and causes problems

I have a table in a sqlite database with the following schema

CREATE TABLE os_logs (version STRING, user STRING, date STRING>;

I set the following command to a variable called cmd.

select count(*), version) 
  from os_logs
  group by version
  order by version;

After I send that command through dbGetQuery I get numeric results back for version instead of a string.

db <- dbConnect(SQLite(),"./os_backup.db")
dbGetQuery(db,cmd)

count(*)    version
1421    NA
1797    0.7
6   0.71
2152    0.71
1123    0.72
3455    1
2335    1

The versions should be

0.70.1111_Product
0.71.22_Dev
0.71.33_Product
...

Any idea on why the strings in my sql database are being turned into numerics in R? If I do that command on the sql cmd line it works perfectly

Aucun commentaire:

Enregistrer un commentaire