hadley/ggplot2 — Issue #299: When range( x ) or range( y ) is large, round_any( x , floor ) returns incorrect number
Author: dnadave
Created: 2011-12-15 20:01:25+00:00
State: open

When the range of x or y is large, the function round_any returns a number out of range for the lower bound resulting in a shape parameter that is too large. This then results in a request for an inordinate amount of RAM which causes qplot to fail.

Here is a small reproduce:

> a <- data.frame( x = c( 1351425 , 2865880767 , 1351425 , 2865880767 ) , y = c( 0.0254 , -0.370578048780488 , -0.399846341463415 , 0.613065853658537 ) )
> b <- qplot( x , y , data = a , geom = "hex" )
> print( b )
Error in vector("integer", length) : vector size specified is too large

The offending lines of code follow:

> grep -Rn round_any ggplot2/R/stat-binhex.r

61: round_any(min(x), binwidth[1], floor) - 1e-6,
62: round_any(max(x), binwidth[1], ceiling) + 1e-6
67: round_any(min(y), binwidth[1], floor) - 1e-6,
68: round_any(max(y), binwidth[2], ceiling) + 1e-6

And, here is my sessionInfo():

> sessionInfo()
R version 2.13.0 (2011-04-13)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] grid tools stats graphics grDevices utils datasets
[8] methods base

other attached packages:
[1] colorspace_1.1-0 hgu95av2_2.2.0 ggdendro_0.1-01 reshape2_1.1
[5] ggplot2_0.8.9 proto_0.3-9.2 reshape_0.8.4 plyr_1.5.2
[9] hexbin_1.26.0 lattice_0.19-26 svmrfe_0.1.0 e1071_1.5-26
[13] class_7.3-3 CNTools_1.8.0 genefilter_1.34.0 Biobase_2.12.1
[17] DNAcopy_1.26.0 rj_0.5.5-4

loaded via a namespace (and not attached):
[1] annotate_1.30.0 AnnotationDbi_1.14.1 DBI_0.2-5
[4] digest_0.5.0 RSQLite_0.9-4 splines_2.13.0
[7] stringr_0.4 survival_2.36-9 xtable_1.5-6

David Henderson