Skip to content

Commit

Permalink
allow multiple group variables in get_best()
Browse files Browse the repository at this point in the history
  • Loading branch information
huizezhang-sherry committed Jun 14, 2024
1 parent 2212dab commit 2a8b0ad
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions R/get.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,20 @@
#' @return a tibble object containing the best basis found by the optimiser(s)
#' @export
get_best <- function(dt, group = NULL) {
group <- rlang::enexpr(group) |> as.list()
if (length(group) != 1) {group <- group[-1]}


search_methods <- unique(dt[["method"]])
if (!"search_jellyfish" %in% search_methods) {
dt <- dt %>% dplyr::filter(.data[["info"]] == "interpolation")
}

res <- dt %>%
dplyr::group_by({{group}}) %>%
dplyr::group_by(!!!group) %>%
dplyr::filter(.data$index_val == max(.data$index_val, na.rm = TRUE)) %>%
dplyr::distinct(.data$index_val, .keep_all = TRUE)
dplyr::distinct(.data$index_val, .keep_all = TRUE) |>
dplyr::ungroup()

res
}
Expand Down

0 comments on commit 2a8b0ad

Please sign in to comment.