Skip to content

Commit

Permalink
take care that input really are integer, not only practically
Browse files Browse the repository at this point in the history
github issue #259: backtransformation to integers can be inexact,
but analysis assumes exact integers because input are truncated.
Now we first check that the values are practically integers, and
then silently take care that they are exactly integers with round().

(cherry picked from commit 87d76f0)
  • Loading branch information
Jari Oksanen committed Dec 11, 2017
1 parent ea4a0c1 commit 13fc048
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions R/rrarefy.R
Expand Up @@ -6,6 +6,8 @@
if (!identical(all.equal(x, round(x)), TRUE))
stop("function is meaningful only for integers (counts)")
x <- as.matrix(x)
## x may not be exactly integer, since, e.g., sqrt(2)^2 != 2
x <- round(x)
if (ncol(x) == 1)
x <- t(x)
if (length(sample) > 1 && length(sample) != nrow(x))
Expand Down

0 comments on commit 13fc048

Please sign in to comment.