diff --git a/R/collapseHz.R b/R/collapseHz.R index b08fb1ff..9492bfc8 100644 --- a/R/collapseHz.R +++ b/R/collapseHz.R @@ -163,11 +163,11 @@ collapseHz <- function(x, labels <- pattern } + h <- data.table::data.table(horizons(x)) + # iterate over patterns for (p in seq(pattern)) { - h <- data.table::data.table(horizons(x)) - # calculate matches if (!is.null(by) && length(pattern) == 1 && is.na(pattern)) { labels <- h[[by]] @@ -271,9 +271,10 @@ collapseHz <- function(x, # sort horizons by id name and top depth h <- h[order(h[[idn]], h[[hzd[1]]]),] - # replace horizons in parent SPC - replaceHorizons(x) <- h } + + # replace horizons in parent SPC + replaceHorizons(x) <- h } x }