Skip to content

Commit

Permalink
check for finite parameters and positive sample size in calc_dist_params
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwlambert committed Nov 13, 2023
1 parent 606a2ae commit e9a27b6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions R/calc_dist_params.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,15 @@ calc_dist_params <- function(prob_dist, # nolint cyclocomp
# extract mean and sd
mean_sd <- c(summary_stats$mean, summary_stats$sd)

is_mean_sd <- checkmate::test_numeric(mean_sd, any.missing = FALSE, len = 2)
is_median_disp <- checkmate::test_numeric(median_disp, len = 2)
is_median_range <- checkmate::test_numeric(median_range, len = 3) &&
checkmate::test_numeric(sample_size, any.missing = FALSE)
is_mean_sd <- checkmate::test_numeric(
mean_sd, any.missing = FALSE, len = 2, finite = TRUE
)
is_median_disp <- checkmate::test_numeric(
median_disp, len = 2, finite = TRUE
)
is_median_range <- checkmate::test_numeric(
median_range, len = 3, finite = TRUE
) && checkmate::test_count(sample_size, positive = TRUE)
# convert from mean and sd
if (is_mean_sd) {
summary_stats_ <- unlist(summary_stats)
Expand Down

0 comments on commit e9a27b6

Please sign in to comment.