<dplyr:::mutate_error/rlang_error/error/condition>
Error in `dplyr::mutate(medicaldata::strep_tb, arm = forcats::fct(as.character(arm), levels = c("Control", "Streptomycin")), dose_strep_g = as.numeric(dose_strep_g), dose_PAS_g = as.numeric(dose_PAS_g), gender = forcats::fct_infreq(gender), baseline_condition = forcats::fct(as.character(baseline_condition), levels = c("1_Good", "2_Fair", "3_Poor")), baseline_temp = forcats::fct(dplyr::case_match(baseline_temp, "1_<=98.9F/37.2C" ~ "<= 37.2C", "2_99-99.9F/37.3-37.7C" ~ "37.3 - 37.7C", "2_99-99.9F/37.3-37.7C/37.3-37.7C" ~      "37.3 - 37.7C", "3_100-100.9F/37.8-38.2C" ~ "37.8 - 38.2C", "3_100-100.9F/37.8-38.2C/37.8-38.2C" ~ "37.8 - 38.2C", "4_>=101F/38.3C" ~ ">= 38.3C"), levels = c("<= 37.2C", "37.3 - 37.7C", "37.8 - 38.2C", ">= 38.3C")), baseline_esr = forcats::fct_na_value_to_level(forcats::fct(dplyr::case_match(baseline_esr, "2_11-20" ~ "11-20", "3_21-50" ~ "21-50", "4_51+" ~ "51+", "<NA>" ~ NA), levels = c("11-20", "21-50", "51+")), level = "NA"), baseline_cavitation = forcats::fct(baseline_cavitation, levels = c("no",      "yes")), radiologic_6m = forcats::fct(radiologic_6m, levels = c("1_Death", "2_Considerable_deterioration", "3_Moderate_deterioration", "4_No_change", "5_Moderate_improvement", "6_Considerable_improvement")))`: i In argument: `baseline_temp = forcats::fct(...)`.
Caused by error in `dplyr::case_match()`:
! Can't convert from `..1 (left)` <character> to <factor<ae9a9>> due to loss of generality.
* Locations: 1

testthat::test_that("`plot_or()` does not produce messages or warnings", {
# iterate over some datasets that should not cause issues
# test that it runs without causing issue using defaults
# test that it runs silently using a different confidence interval
# test that it runs silently using fast CI estimation
assumption_checks = FALSE # needed because nhanes results in warning re: separation with fast confint method
testthat::test_that("`table_or()` does not produce messages or warnings", {
# get models that should not cause issues
# combined uni- and multivariable summary as tibble
plotor::table_or(.x, output = "tibble", output_type = "uni_and_multi")
# combined uni- and multivariable summary as gt
plotor::table_or(.x, output = "gt", output_type = "uni_and_multi")
# These tests are suspended because different versions of {ggplot2}
# produce identical-looking plots but are somehow different internally which
# results in these tests failing if they don't use the same version of {ggplot2}
# which produced the snapshot. See issue #68 for details.
# testthat::test_that("`plot_or()` produces plots equivalent to a snapshot", {
#       lr <- readRDS(file = testthat::test_path('test_data', 'lr_titanic.Rds'))
#       lr <- readRDS(file = testthat::test_path('test_data', 'lr_diabetes.Rds'))
testthat::test_that("`table_or()` and `plot_or()` handle issues gracefully", {
## test `assumption_checks` parameter works
# setting to `FALSE` with models with known issues should not result in warnings
testthat::test_that("`assumption_checks` parameter works as expected", {
# 1. list some models that result in at least one warning for assumptions
# NB, diabetes may not be an exported object from 'medicaldata'
# list_models <- list(get_lr_diabetes(), get_lr_infert())
# test that warnings are not raised if `assumption_checks` is FALSE
testthat::test_that("`validate_conf_level_input()` works as expected", {
# inputs which are not single value and numeric
# inputs outside expected range - parse to valid inputs
# inputs outside expected range - expect messages informing of the change
testthat::test_that("`validate_output_table_input()` works as expected", {
# inputs not in the expected list - expect a warning
testthat::test_that("`validate_output_table_type_input()` works as expected", {
testthat::test_that("`assumption_binary_outcome()` works as expected", {
# expect no error from generating the data
# raise error for models with more than two outcome levels
testthat::test_that("`assumption_no_multicollinearity()` works as expected", {
# successfully generate datasets with high correlation
# these datasets should result in warnings when tested re: high correlations
# they should also result in messages recommending the `plotor::check_or()` function
# expecting to warn twice - once for multicollinearity and again for sample size
# as well as messages re: `plotor::check_or()`
testthat::test_that("`assumption_no_separation()` works as expected", {
# expecting an error just from getting the data
# raise warning message for models with separation
testthat::test_that("`assumption_no_separation_fast()` works as expected", {
testthat::test_that("`assumption_sample_size()` works as expected", {
# raise a warning message for models with too few observations
# list_models <- list(get_lr_titanic(), get_lr_infert(), get_lr_diabetes())
# run the test that a warning is expected
testthat::test_that("`assumption_linearity()` works as expected", {
# raise a warning message for models with non-linear relationships between a continuous predictor and the outcome
# 1. list some models to test for non-linearity