Skip to content

Commit

Permalink
Better check of maxDistance argument in Trace method
Browse files Browse the repository at this point in the history
  • Loading branch information
stewid committed Jan 21, 2017
1 parent 7627b48 commit d66aec9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions R/trace.r
Original file line number Diff line number Diff line change
Expand Up @@ -438,12 +438,13 @@ Trace <- function(movements,
##
if (is.null(maxDistance)) {
maxDistance <- 0L
} else if (!is.numeric(maxDistance)) {
stop("'maxDistance' must be an integer")
}

if (!is_wholenumber(maxDistance)) {
stop("'maxDistance' must be an integer")
if (!all(identical(is.numeric(maxDistance), TRUE),
identical(length(maxDistance), 1L),
identical(is_wholenumber(maxDistance), TRUE),
as.integer(maxDistance) >= 0L)) {
stop("'maxDistance' must be an integer >= 0")
}

## Arguments seems ok...go on with contact tracing
Expand Down

0 comments on commit d66aec9

Please sign in to comment.