[R-sig-DB] query result precision

Kasper Daniel Hansen kh@n@en @end|ng |rom @t@t@Berke|ey@EDU
Mon May 12 05:28:06 CEST 2008


Are you sure that you do not get all the digits? Try
   print(fetch(rs, n = -1), digits = 15)

The default option of "digits" is 7 and it might hit you here.

Kasper

On May 11, 2008, at 8:15 PM, William Morris wrote:

> In R, using RSQLite, I get a maximum of 4 digits after the decimal  
> point for every value returned from a query, whereas the same select  
> statement executed with 'sqlite3' (at the command line) gives each  
> value without rounding. How can I get R to give the same output?
>
> Cheers in advance,
>
> Will.
>
> in R
>
> > m <- dbDriver("SQLite")
> > con <- dbConnect(m,"database.sqlite")
> > rs <- dbSendQuery(con,"select col1 from table1 limit 10")
> > fetch(rs,n=-1)
>   col1
> 1   145.0836
> 2   145.0836
> 3   145.0836
> 4   145.0836
> 5   145.0836
> 6   145.0836
> 7   144.0681
> 8   144.0681
> 9   144.0681
> 10  144.0681
>
> in sqlite3
>
> sqlite> select col1 from table1 limit 10;
> 145.08361
> 145.08361
> 145.08361
> 145.08361
> 145.08361
> 145.08361
> 144.06806
> 144.06806
> 144.06806
> 144.06806
>
> R session info
>
> sessionInfo()
> R version 2.7.0 Patched (2008-05-10 r45665)
> i386-apple-darwin8.10.1
>
> locale:
> en_AU.UTF-8/en_AU.UTF-8/C/C/en_AU.UTF-8/en_AU.UTF-8
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> other attached packages:
> [1] RSQLite_0.6-8 DBI_0.2-4
>
> loaded via a namespace (and not attached):
> [1] tools_2.7.0
>
> _______________________________________________
> R-sig-DB mailing list -- R Special Interest Group
> R-sig-DB using stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-db




More information about the R-sig-DB mailing list