Skip to content

Commit

Permalink
fixed sd_ and inference_method assignment and param_type subsetting i…
Browse files Browse the repository at this point in the history
…n epireview_to_epidist
  • Loading branch information
joshwlambert committed Jun 14, 2024
1 parent a7d6b96 commit 0f805b9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion R/coercion.R
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ epireview_to_epidist <- function(x, ...) {
)
epi_dist <- .unique(x$parameter_type, var_name = "parameter types")
prob_dist <- .unique(x$distribution_type, var_name = "distribution types")
sd_ <- NULL
if (rlang::is_na(prob_dist)) {
prob_dist_params <- NA_real_
uncertainty <- create_epidist_uncertainty()
Expand Down Expand Up @@ -299,7 +300,6 @@ epireview_to_epidist <- function(x, ...) {
)
prob_dist_params_names <- .clean_string(prob_dist_params_names)
names(prob_dist_params) <- prob_dist_params_names
sd_ <- NULL
if (all(c("mean", "sd") %in% names(prob_dist_params))) {
sd_ <- prob_dist_params[["sd"]]
prob_dist_params <- do.call(
Expand All @@ -325,6 +325,8 @@ epireview_to_epidist <- function(x, ...) {
"NA" = NULL,
stop("Parameter value type not recognised", call. = FALSE)
)
# ensure param_type is unnamed vector as it is used for list subsetting
param_type <- unlist(unname(param_type))
is_other <- vapply(
param_type,
rlang::is_chr_na,
Expand All @@ -346,6 +348,7 @@ epireview_to_epidist <- function(x, ...) {
)
if (grepl(pattern = "Range", x = uncertainty_type, fixed = TRUE)) {
summary_stats$range <- c(x$parameter_lower_bound, x$parameter_upper_bound)
inference_method <- NA
} else if (grepl(pattern = "CI", x = uncertainty_type, fixed = TRUE)) {
summary_stats <- .ss_ci(x, summary_stats, param_type)
inference_method <- "Maximum likelihood"
Expand Down

0 comments on commit 0f805b9

Please sign in to comment.