Skip to content

Commit

Permalink
use base pipe in fit_model() on n2kComposite
Browse files Browse the repository at this point in the history
  • Loading branch information
ThierryO committed Oct 27, 2024
1 parent e65e559 commit 953668b
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions R/fit_model_n2k_composite.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' @rdname fit_model
#' @importFrom methods setMethod new
#' @importFrom dplyr %>% filter group_by n summarise transmute mutate arrange
#' @importFrom dplyr arrange filter group_by mutate n summarise transmute
#' @importFrom rlang .data
#' @importFrom utils file_test
#' @importFrom stats qnorm
Expand All @@ -21,30 +21,28 @@ setMethod(
status(x) <- "error"
return(x)
}
x@Parameter %>%
filter(!is.na(.data$estimate), !is.na(.data$variance)) %>%
group_by(.data$value) %>%
x@Parameter |>
filter(!is.na(.data$estimate), !is.na(.data$variance)) |>
group_by(.data$value) |>
summarise(
estimate = mean(.data$estimate),
se = sqrt(sum(.data$variance)) / n()
) %>%
estimate = mean(.data$estimate), se = sqrt(sum(.data$variance)) / n()
) |>
transmute(
.data$value,
.data$estimate,
.data$value, .data$estimate,
lower_confidence_limit =
qnorm(0.025, mean = .data$estimate, sd = .data$se),
upper_confidence_limit =
qnorm(0.975, mean = .data$estimate, sd = .data$se)
) %>%
) |>
as.data.frame() -> x@Index
status(x) <- "converged"
return(x)
}

status(x) <- "waiting"
parent_status <- parent_status(x)
parent_status %>%
filter(.data$parent_status %in% c("new", "waiting", status)) %>%
parent_status |>
filter(.data$parent_status %in% c("new", "waiting", status)) |>
pull("parent_analysis") -> todo

for (this_parent in todo) {
Expand All @@ -67,12 +65,12 @@ setMethod(
] <- get_status_fingerprint(model)
x@AnalysisRelation <- parent_status
if (status(model) == "converged") {
extract(extractor = x@Extractor, object = model) %>%
mutate(parent = this_parent) %>%
extract(extractor = x@Extractor, object = model) |>
mutate(parent = this_parent) |>
bind_rows(
x@Parameter %>%
x@Parameter |>
filter(.data$parent != this_parent)
) %>%
) |>
arrange(.data$parent, .data$value) -> x@Parameter
}
}
Expand Down

0 comments on commit 953668b

Please sign in to comment.