Skip to content

Commit

Permalink
move horizon extraction and replacement outside the loop
Browse files Browse the repository at this point in the history
  • Loading branch information
brownag committed Oct 11, 2024
1 parent 0098010 commit 424ebbe
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions R/collapseHz.R
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 424ebbe

Please sign in to comment.