diff --git a/NEWS.md b/NEWS.md index 23e16de..b69c791 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,11 @@ ## Bug fixes +- Fixed a bug in which `cost_to_closest()` would return `NA` values when + filling missing ids (which should be filled with `Inf`, since they cannot + reach any opportunities). This was also responsible for the warning reported + in #27, which was also fixed. + ## Notes # accessibility 1.0.0 diff --git a/R/cost_to_closest.R b/R/cost_to_closest.R index ff19b2f..c5548de 100644 --- a/R/cost_to_closest.R +++ b/R/cost_to_closest.R @@ -115,6 +115,8 @@ cost_to_closest <- function(travel_matrix, possible_combinations <- do.call(data.table::CJ, unique_values) if (nrow(access) < nrow(possible_combinations)) { + access[, min_cost := as.numeric(min_cost)] + access <- do_fill_missing_ids( access, possible_combinations,