Skip to content

Commit

Permalink
Fix 🐛 in write_profile()
Browse files Browse the repository at this point in the history
  • Loading branch information
mrustl committed Jul 9, 2024
1 parent 25bc249 commit 143ef31
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions R/write_profile.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,29 +103,32 @@ write_profile <- function(profile,
profile$mat_props <- tibble::tibble(mat_id = unique(profile$profile$mat),
mat_depth = if(n_materials > 1) {
c(rep(0, n_materials-1), min(profile$profile$x)
)},
)} else {min(profile$profile$x)},
mat_prop3 = 1,
mat_prop4 = 1)
}


obsnodes <- if(is.null(profile$obsnodes$n)) {
obsnodes <- stringr::str_pad(0,width = 5,side = "left")
} else {
if(profile$obsnodes$n > 0) {
obsnodes <- if(profile$obsnodes$n > 0) {
if(max(profile$obsnodes$ids) > max(profile$profile$node_id)) {
valid_ids <- which(profile$obsnodes$ids <= max(profile$profile$node_id))
profile$obsnodes$ids <- profile$obsnodes$ids[valid_ids]
profile$obsnodes$n <- length(profile$obsnodes$ids)
}

stringr::str_pad(profile$obsnodes$n,width = 5,side = "left")
}

obsnodes <- if(is.null(profile$obsnodes$n) | profile$obsnodes$n == 0) {
obsnodes <- stringr::str_pad(0,width = 5,side = "left")
} else {
stringr::str_pad(profile$obsnodes$n,width = 5,side = "left")
}

obsnodes <- c(obsnodes,
paste0(stringr::str_pad(profile$obsnodes$ids,width = 5,side = "left"),
obsnodes <- c(obsnodes,
paste0(stringr::str_pad(profile$obsnodes$ids,width = 5,side = "left"),
collapse = ""))
}


headers_profile_base <- c(stringr::str_pad(c(max(profile$profile$node_id),
1,
Expand Down

0 comments on commit 143ef31

Please sign in to comment.