For information on using this system, please visit this page.

Bug 17286 - fourfoldplot() fails on moderately large integer values
Summary: fourfoldplot() fails on moderately large integer values
Status: CLOSED FIXED
Alias: None
Product: R
Classification: Unclassified
Component: Misc (show other bugs)
Version: R 3.4.0
Hardware: x86_64/x64/amd64 (64-bit) Linux
: P5 minor
Assignee: R-core
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-14 21:05 UTC by Dirk Eddelbuettel
Modified: 2017-06-15 20:32 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Eddelbuettel 2017-06-14 21:05:32 UTC
fourfoldplot() fails to overflow with values that are not all that large

R> fourfoldplot(as.table(matrix(c(100000L, 80000L, 60000L, 120000L),2,2)))
Error in if (or == 1) x <- t * n/(m + n) else if (or == Inf) x <- max(0,  : 
  missing value where TRUE/FALSE needed
In addition: Warning messages:
1: In f[1L, 1L] * f[2L, 2L] : NAs produced by integer overflow
2: In f[1L, 2L] * f[2L, 1L] : NAs produced by integer overflow
3: In f[1L, 1L] * f[2L, 2L] : NAs produced by integer overflow
4: In f[1L, 2L] * f[2L, 1L] : NAs produced by integer overflow
5: In f[1L, 1L] * f[2L, 2L] : NAs produced by integer overflow
6: In f[1L, 2L] * f[2L, 1L] : NAs produced by integer overflow
R> fourfoldplot(as.table(matrix(c(1000L, 800L, 600L, 1200L),2,2)))  # passes
R> fourfoldplot(as.table(matrix(c(10000L, 8000L, 6000L, 12000L) * 1.0,2,2)))
R> 

As you can see, it passes with values one order of magnitude smaller ... or the
same values stored as numeric.
Comment 1 Peter Dalgaard 2017-06-14 21:27:55 UTC
Last example is off by a factor of 10, but I get the point. 

Presumably an as.double() applied to f inside the function odds() could fix this.
Comment 2 Dirk Eddelbuettel 2017-06-14 21:30:52 UTC
Sorry for the imprecise wording:

i)   call fails as integer
ii)  call passes with values that 1/10 of original values, still integer
iii) call passes with original values _once turned to double_

And agreed, there is probably a cheap conversion inside we should apply.
Comment 3 Peter Dalgaard 2017-06-15 20:32:34 UTC
Nothing wrong with the wording, but you divided by _100_ then multiplied by 10 and converted to double.

Anyways, this is now fixed in R-patched and R-devel.