diff --git a/R/coev_helpers.R b/R/coev_helpers.R index dea437c..d778ef6 100644 --- a/R/coev_helpers.R +++ b/R/coev_helpers.R @@ -46,7 +46,8 @@ run_checks <- function(data, variables, id, tree, effects_mat, stop2( paste0( "Variables following the 'bernoulli_logit' response distribution ", - "must be integers with values of 0/1 in the data." + "must be integers with values of 0/1 in the data. Try using the ", + "as.integer() function to convert variables to integers." ) ) } @@ -58,7 +59,8 @@ run_checks <- function(data, variables, id, tree, effects_mat, stop2( paste0( "Variables following the 'ordered_logistic' response distribution ", - "must be ordered factors in the data." + "must be ordered factors in the data. Try using the as.ordered() ", + "function to convert variables to ordered factors." ) ) } @@ -72,7 +74,8 @@ run_checks <- function(data, variables, id, tree, effects_mat, stop2( paste0( "Variables following the 'poisson_softplus' response distribution ", - "must be integers greater than or equal to zero in the data." + "must be integers greater than or equal to zero in the data. Try ", + "using the as.integer() function to convert variables to integers." ) ) } @@ -84,7 +87,8 @@ run_checks <- function(data, variables, id, tree, effects_mat, paste0( "Variables following the 'negative_binomial_softplus' response ", "distribution must be integers greater than or equal to zero in ", - "the data." + "the data. Try using the as.integer() function to convert variables ", + "to integers." ) ) } diff --git a/tests/testthat/test-coev_fit.R b/tests/testthat/test-coev_fit.R index 0d0c2f5..b997679 100644 --- a/tests/testthat/test-coev_fit.R +++ b/tests/testthat/test-coev_fit.R @@ -99,8 +99,10 @@ test_that("coev_fit() produces expected errors", { ), paste0( "Variables following the 'bernoulli_logit' response distribution ", - "must be integers with values of 0/1 in the data." - ) + "must be integers with values of 0/1 in the data. Try using the ", + "as.integer() function to convert variables to integers." + ), + fixed = TRUE ) expect_error( coev_fit( @@ -114,8 +116,10 @@ test_that("coev_fit() produces expected errors", { ), paste0( "Variables following the 'ordered_logistic' response distribution ", - "must be ordered factors in the data." - ) + "must be ordered factors in the data. Try using the as.ordered() ", + "function to convert variables to ordered factors." + ), + fixed = TRUE ) expect_error( coev_fit( @@ -129,8 +133,10 @@ test_that("coev_fit() produces expected errors", { ), paste0( "Variables following the 'poisson_softplus' response distribution ", - "must be integers greater than or equal to zero in the data." - ) + "must be integers greater than or equal to zero in the data. Try ", + "using the as.integer() function to convert variables to integers." + ), + fixed = TRUE ) expect_error( coev_fit( @@ -145,8 +151,10 @@ test_that("coev_fit() produces expected errors", { paste0( "Variables following the 'negative_binomial_softplus' response ", "distribution must be integers greater than or equal to zero in ", - "the data." - ) + "the data. Try using the as.integer() function to convert variables ", + "to integers." + ), + fixed = TRUE ) expect_error( coev_make_stancode( diff --git a/tests/testthat/test-coev_make_stancode.R b/tests/testthat/test-coev_make_stancode.R index 04a767f..5317dc9 100644 --- a/tests/testthat/test-coev_make_stancode.R +++ b/tests/testthat/test-coev_make_stancode.R @@ -99,8 +99,10 @@ test_that("coev_make_stancode() produces expected errors", { ), paste0( "Variables following the 'bernoulli_logit' response distribution ", - "must be integers with values of 0/1 in the data." - ) + "must be integers with values of 0/1 in the data. Try using the ", + "as.integer() function to convert variables to integers." + ), + fixed = TRUE ) expect_error( coev_make_stancode( @@ -114,8 +116,10 @@ test_that("coev_make_stancode() produces expected errors", { ), paste0( "Variables following the 'ordered_logistic' response distribution ", - "must be ordered factors in the data." - ) + "must be ordered factors in the data. Try using the as.ordered() ", + "function to convert variables to ordered factors." + ), + fixed = TRUE ) expect_error( coev_make_stancode( @@ -129,8 +133,10 @@ test_that("coev_make_stancode() produces expected errors", { ), paste0( "Variables following the 'poisson_softplus' response distribution ", - "must be integers greater than or equal to zero in the data." - ) + "must be integers greater than or equal to zero in the data. Try ", + "using the as.integer() function to convert variables to integers." + ), + fixed = TRUE ) expect_error( coev_make_stancode( @@ -145,8 +151,10 @@ test_that("coev_make_stancode() produces expected errors", { paste0( "Variables following the 'negative_binomial_softplus' response ", "distribution must be integers greater than or equal to zero in ", - "the data." - ) + "the data. Try using the as.integer() function to convert variables ", + "to integers." + ), + fixed = TRUE ) expect_error( coev_make_stancode( diff --git a/tests/testthat/test-coev_make_standata.R b/tests/testthat/test-coev_make_standata.R index ade789c..14c6e83 100644 --- a/tests/testthat/test-coev_make_standata.R +++ b/tests/testthat/test-coev_make_standata.R @@ -99,8 +99,10 @@ test_that("coev_make_standata() produces expected errors", { ), paste0( "Variables following the 'bernoulli_logit' response distribution ", - "must be integers with values of 0/1 in the data." - ) + "must be integers with values of 0/1 in the data. Try using the ", + "as.integer() function to convert variables to integers." + ), + fixed = TRUE ) expect_error( coev_make_standata( @@ -114,8 +116,10 @@ test_that("coev_make_standata() produces expected errors", { ), paste0( "Variables following the 'ordered_logistic' response distribution ", - "must be ordered factors in the data." - ) + "must be ordered factors in the data. Try using the as.ordered() ", + "function to convert variables to ordered factors." + ), + fixed = TRUE ) expect_error( coev_make_standata( @@ -129,8 +133,10 @@ test_that("coev_make_standata() produces expected errors", { ), paste0( "Variables following the 'poisson_softplus' response distribution ", - "must be integers greater than or equal to zero in the data." - ) + "must be integers greater than or equal to zero in the data. Try ", + "using the as.integer() function to convert variables to integers." + ), + fixed = TRUE ) expect_error( coev_make_standata( @@ -145,8 +151,10 @@ test_that("coev_make_standata() produces expected errors", { paste0( "Variables following the 'negative_binomial_softplus' response ", "distribution must be integers greater than or equal to zero in ", - "the data." - ) + "the data. Try using the as.integer() function to convert variables ", + "to integers." + ), + fixed = TRUE ) expect_error( coev_make_stancode(