Skip to content
Prev 256741 / 398506 Next

Decimals in R/SQL

You at least have to provide a subset of 'ss09' so we can see what the
original data looks like.  I have not had any problems with decimals
in using sqldf.
+     select key, sum(V1 * V2) / sum(V3)
+         from x
+         group by key
+ ')
key sum(V1 * V2) / sum(V3)
1   1               19.38166
2   2               17.40503
3   3               71.48818
structure(list(key = 1:3, `sum(V1 * V2) / sum(V3)` = c(19.3816573628268,
17.4050302312273, 71.4881812227571)), .Names = c("key", "sum(V1 * V2) / sum(V3)"
), row.names = c(NA, 3L), class = "data.frame")

        
On Wed, Apr 13, 2011 at 11:10 AM, Rachel Licata <RachelL at kff.org> wrote: