From 41e151c7ba0a1bbbe75c029379058c247de00c79 Mon Sep 17 00:00:00 2001 From: Giorgio Comai Date: Tue, 5 Nov 2024 10:17:42 +0100 Subject: [PATCH] fix when no occurrence in a given plane --- R/rv_create_risk_vector.R | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/R/rv_create_risk_vector.R b/R/rv_create_risk_vector.R index edbaa4b..0afe5c9 100644 --- a/R/rv_create_risk_vector.R +++ b/R/rv_create_risk_vector.R @@ -89,6 +89,10 @@ rv_create_risk_vector <- function(risk_ratio, risk_places_v <- rep(as.character(NA), total_places) for (i in (unique(risk_ratio[[1]])[is.na(unique(risk_ratio[[1]])) == FALSE])) { + if (sum(is.na(risk_places_v))==0) { + break + } + selector <- sample( x = seq_along(risk_places_v[is.na(risk_places_v) == TRUE]), replace = FALSE,