From f25246d532df24cc98b16e298165e1618b2997c1 Mon Sep 17 00:00:00 2001 From: Andrew Gene Brown Date: Fri, 31 May 2024 16:58:12 -0700 Subject: [PATCH] glom: fix edge case for https://github.com/ncss-tech/aqp/issues/180#issuecomment-2143114675 - failed to insert filled horizons when specified interval intersected no horizons --- R/glom.R | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/R/glom.R b/R/glom.R index 8bc7f450d..2f517edbb 100644 --- a/R/glom.R +++ b/R/glom.R @@ -259,20 +259,20 @@ setMethod("glom", signature(p = "SoilProfileCollection"), p <- .updateSite(p, h) } - if (nrow(h) > 0) { - if (!fill) { + if (fill) { + p <- .insert_dropped_horizons(p, horizons = h) + } else { + if (nrow(h) > 0) { # replace @horizons with h replaceHorizons(p) <- h # if pre-existing "filled" horizons are present, drop them p <- p[!isEmpty(p),] } else { - p <- .insert_dropped_horizons(p, horizons = h) + p <- p[0, ] } - } else { - p <- p[0,] } - + # short circuit to get hzIDs of result if (ids) { if (invert)