Skip to content

Commit

Permalink
Remove duplicated node_id soil zone is extended
Browse files Browse the repository at this point in the history
  • Loading branch information
mrustl committed Jul 10, 2024
1 parent dd69e56 commit 568c595
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion R/extend_soil_profile.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@
#' @importFrom dplyr arrange bind_rows
#'
extend_soil_profile <- function(df, x_end) {

shorten_profile <- FALSE

if (x_end > min(df$x)) {
if (any(x_end == df$x)) {
shorten_profile <- TRUE
return(df[which(x_end <= df$x), ])
}
} else {
Expand Down Expand Up @@ -40,7 +44,11 @@ extend_soil_profile <- function(df, x_end) {
}

# Kombinieren und Sortieren der Dataframes
combined_df <- dplyr::bind_rows(df, new_df)
combined_df <- if(shorten_profile) {
dplyr::bind_rows(df, new_df)
} else {
dplyr::bind_rows(df, new_df[-1,])
}
sorted_df <- dplyr::arrange(combined_df, node_id)

return(sorted_df)
Expand Down

0 comments on commit 568c595

Please sign in to comment.