
Validate a pmx_stats container
Source: R/doseprop_stats.R, R/forest_stats.R, R/pmx_stats.R, and 1 more
validate_pmx_stats.RdChecks that x is a well-formed pmx_stats container and returns it
invisibly, or aborts with an error of class pmxhelpr_error_bad_stats
naming what is wrong. Use it after editing a container (e.g. x$stats) or
building one by hand with pmx_stats(); is_pmx_stats() with
strict = TRUE runs the same checks but returns TRUE/FALSE.
The generic dispatches on the container class:
vpc_stats: the bin, count and quantile columns ofstats; theOBSDV/PC_OBSDV/TIMEcolumns ofobs; then_replicates,ci,pi,loqandstrat_varconfig keys; and thesim_prop_blq_*columns whenconfig$loqis set.doseprop_stats: the power-model columns ofstats, anobsframe holding theconfigmetric and dose columns, and themetric_name_var,metric_value_var,dose_varandciconfig keys.forest_stats: the estimate, label,is_refandlayoutcolumns ofstatswith their types and values, theconfiggrouping columns, and validconfig$ciandconfig$sigdigits.Any other object:
xmust carry thepmx_statsclass and have astatsdata.frame, anobsdata.frame orNULL, and aconfiglist. Packages defining their ownpmx_statssubclass can add a method.
Usage
# S3 method for class 'doseprop_stats'
validate_pmx_stats(
x,
...,
arg = rlang::caller_arg(x),
call = rlang::caller_env()
)
# S3 method for class 'forest_stats'
validate_pmx_stats(
x,
...,
arg = rlang::caller_arg(x),
call = rlang::caller_env()
)
validate_pmx_stats(
x,
...,
arg = rlang::caller_arg(x),
call = rlang::caller_env()
)
# Default S3 method
validate_pmx_stats(
x,
...,
arg = rlang::caller_arg(x),
call = rlang::caller_env()
)
# S3 method for class 'vpc_stats'
validate_pmx_stats(
x,
...,
arg = rlang::caller_arg(x),
call = rlang::caller_env()
)See also
Other pmx stats class:
is_pmx_stats(),
pmx_stats()
Examples
fs <- df_forest(data_sad_pkforest)
validate_pmx_stats(fs)
fs$stats$est <- as.character(fs$stats$est)
try(validate_pmx_stats(fs))
#> Error in eval(expr, envir) :
#> `fs$stats` column `est` must be numeric.