diff --git a/R/estimate_density.R b/R/estimate_density.R index 80329b599..a8307c37c 100644 --- a/R/estimate_density.R +++ b/R/estimate_density.R @@ -376,9 +376,9 @@ estimate_density.emmGrid <- function(x, ) # This doesn't use .append_datagrid because we get a non-grid output - grid <- insight::get_datagrid(x) - grid$Parameter <- unique(out$Parameter) - out <- datawizard::data_join(grid, out, by = "Parameter") + dgrid <- insight::get_datagrid(x) + dgrid$Parameter <- unique(out$Parameter) + out <- datawizard::data_join(dgrid, out, by = "Parameter") out$Parameter <- NULL class(out) <- .set_density_class(out) out @@ -398,15 +398,15 @@ estimate_density.slopes <- function(x, xdf <- .get_marginaleffects_draws(x) out <- estimate_density(xdf, - method = method, precision = precision, - extend = extend, extend_scale = extend_scale, - bw = bw, ... + method = method, precision = precision, + extend = extend, extend_scale = extend_scale, + bw = bw, ... ) # This doesn't use .append_datagrid because we get a non-grid output - grid <- insight::get_datagrid(x) - grid$Parameter <- unique(out$Parameter) - out <- datawizard::data_join(grid, out, by = "Parameter") + dgrid <- insight::get_datagrid(x) + dgrid$Parameter <- unique(out$Parameter) + out <- datawizard::data_join(dgrid, out, by = "Parameter") out$Parameter <- NULL class(out) <- .set_density_class(out) out diff --git a/R/format.R b/R/format.R index 15c205e48..3d81e4734 100644 --- a/R/format.R +++ b/R/format.R @@ -103,7 +103,8 @@ format.bayesfactor_models <- function(x, BFE$log_BF <- as.numeric(x, log = log) BFE$BF <- insight::format_bf(abs(BFE$log_BF), name = NULL, exact = exact, ...) - if (any((sgn <- sign(BFE$log_BF) < 0)[!is.na(BFE$log_BF)])) { + sgn <- sign(BFE$log_BF) + if (any((sgn < 0)[!is.na(BFE$log_BF)])) { BFE$BF[sgn] <- paste0("-", BFE$BF[sgn]) } @@ -170,7 +171,8 @@ format.bayesfactor_inclusion <- function(x, BFE$log_BF <- as.numeric(x, log = log) BFE$BF <- insight::format_bf(abs(BFE$log_BF), name = NULL, exact = exact, ...) - if (any((sgn <- sign(BFE$log_BF) < 0)[!is.na(BFE$log_BF)])) { + sgn <- sign(BFE$log_BF) + if (any((sgn < 0)[!is.na(BFE$log_BF)])) { BFE$BF[sgn] <- paste0("-", BFE$BF[sgn]) } @@ -221,7 +223,8 @@ format.bayesfactor_restricted <- function(x, BFE$log_BF <- as.numeric(x, log = log) BFE$BF <- insight::format_bf(abs(BFE$log_BF), name = NULL, exact = exact, ...) - if (any((sgn <- sign(BFE$log_BF) < 0)[!is.na(BFE$log_BF)])) { + sgn <- sign(BFE$log_BF) + if (any((sgn < 0)[!is.na(BFE$log_BF)])) { BFE$BF[sgn] <- paste0("-", BFE$BF[sgn]) } BFE$log_BF <- NULL @@ -267,7 +270,8 @@ format.bayesfactor_parameters <- function(x, x$BF_override <- insight::format_bf(abs(x$log_BF), name = NULL, exact = exact, ...) - if (any((sgn <- sign(x$log_BF) < 0)[!is.na(x$log_BF)])) { + sgn <- sign(x$log_BF) + if (any((sgn < 0)[!is.na(x$log_BF)])) { x$BF_override[sgn] <- paste0("-", x$BF_override[sgn]) } x$log_BF <- NULL diff --git a/tests/testthat/test-emmGrid.R b/tests/testthat/test-emmGrid.R index 672b2ea58..ed05ad940 100644 --- a/tests/testthat/test-emmGrid.R +++ b/tests/testthat/test-emmGrid.R @@ -49,65 +49,65 @@ test_that("emmGrid point_estimate", { test_that("emmGrid ci", { xci <- ci(all_, ci = 0.9) expect_identical(colnames(xci)[1:2], c("group", "contrast")) - expect_equal(length(xci$CI_low), 3) - expect_equal(length(xci$CI_high), 3) + expect_length(xci$CI_low, 3) + expect_length(xci$CI_high, 3) }) test_that("emmGrid eti", { xeti <- eti(all_, ci = 0.9) expect_identical(colnames(xeti)[1:2], c("group", "contrast")) - expect_equal(length(xeti$CI_low), 3) - expect_equal(length(xeti$CI_high), 3) + expect_length(xeti$CI_low, 3) + expect_length(xeti$CI_high, 3) }) test_that("emmGrid equivalence_test", { xeqtest <- equivalence_test(all_, ci = 0.9, range = c(-0.1, 0.1)) expect_identical(colnames(xeqtest)[1:2], c("group", "contrast")) - expect_equal(length(xeqtest$ROPE_Percentage), 3) - expect_equal(length(xeqtest$ROPE_Equivalence), 3) + expect_length(xeqtest$ROPE_Percentage, 3) + expect_length(xeqtest$ROPE_Equivalence, 3) }) test_that("emmGrid estimate_density", { xestden <- estimate_density(c_, method = "logspline", precision = 5) expect_identical(colnames(xestden)[1], "contrast") - expect_equal(length(xestden$x), 5) + expect_length(xestden$x, 5) }) test_that("emmGrid map_estimate", { xmapest <- map_estimate(all_, method = "kernel") expect_identical(colnames(xmapest)[1:2], c("group", "contrast")) - expect_equal(length(xmapest$MAP_Estimate), 3) + expect_length(xmapest$MAP_Estimate, 3) }) test_that("emmGrid p_direction", { xpd <- p_direction(all_, method = "direct") expect_identical(colnames(xpd)[1:2], c("group", "contrast")) - expect_equal(length(xpd$pd), 3) + expect_length(xpd$pd, 3) }) test_that("emmGrid p_map", { xpmap <- p_map(all_, precision = 2^9) expect_identical(colnames(xpmap)[1:2], c("group", "contrast")) - expect_equal(length(xpmap$p_MAP), 3) + expect_length(xpmap$p_MAP, 3) }) test_that("emmGrid p_rope", { xprope <- p_rope(all_, range = c(-0.1, 0.1)) expect_identical(colnames(xprope)[1:2], c("group", "contrast")) - expect_equal(length(xprope$p_ROPE), 3) + expect_length(xprope$p_ROPE, 3) }) test_that("emmGrid p_significance", { xsig <- p_significance(all_, threshold = c(-0.1, 0.1)) expect_identical(colnames(xsig)[1:2], c("group", "contrast")) - expect_equal(length(xsig$ps), 3) + expect_length(xsig$ps, 3) }) test_that("emmGrid rope", { xrope <- rope(all_, range = "default", ci = 0.9) expect_identical(colnames(xrope)[1:2], c("group", "contrast")) - expect_equal(length(xrope$ROPE_Percentage), 3) + expect_length(xrope$ROPE_Percentage, 3) })