Skip to content

Commit

Permalink
nested
Browse files Browse the repository at this point in the history
  • Loading branch information
wolski committed Sep 24, 2024
1 parent 593f891 commit 73bf9a7
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions R/tidyMS_aggregation.R
Original file line number Diff line number Diff line change
Expand Up @@ -581,15 +581,21 @@ estimate_intensity <- function(data, config, .func)
config <- config$clone(deep = TRUE)

xnested <- data |> group_by_at(config$table$hierarchy_keys_depth()) |> nest()
pb <- progress::progress_bar$new(total = nrow(xnested))
message("starting aggregation")

res <- vector( mode = "list" , length = nrow(xnested) )
for (i in seq_len(nrow(xnested))) {
pb$tick()
aggr <- .func(xnested$data[[i]], config)
res[[i]] <- .reestablish_condition(xnested$data[[i]], aggr , config)

loopOverNested <- function (xnested, .func, config) {
pb <- progress::progress_bar$new(total = nrow(xnested))
message("starting aggregation")
res <- vector( mode = "list" , length = nrow(xnested) )
for (i in seq_len(nrow(xnested))) {
pb$tick()
aggr <- .func(xnested$data[[i]], config)
res[[i]] <- .reestablish_condition(xnested$data[[i]], aggr , config)
}
}

res <- loopOverNested(xnested, .func = .func , config = config)

xnested[[makeName]] <- res
newconfig <- make_reduced_hierarchy_config(
config,
Expand Down

0 comments on commit 73bf9a7

Please sign in to comment.