diff --git a/DESCRIPTION b/DESCRIPTION index 33793897c..d7c30cb7e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: parameters Title: Processing of Model Parameters -Version: 0.30.0.11 +Version: 0.30.0.12 Authors@R: c(person(given = "Daniel", family = "Lüdecke", diff --git a/NAMESPACE b/NAMESPACE index bb8f68eb7..92a5229b2 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -811,6 +811,8 @@ S3method(standard_error,cpglmm) S3method(standard_error,crch) S3method(standard_error,crq) S3method(standard_error,data.frame) +S3method(standard_error,datawizard_kurtosis) +S3method(standard_error,datawizard_skewness) S3method(standard_error,default) S3method(standard_error,deltaMethod) S3method(standard_error,draws) diff --git a/NEWS.md b/NEWS.md index 1d1e70b90..817955a4a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -53,6 +53,9 @@ this failed with an error. An invalid value for `p_adjust` no longer shows the method in the footer of the printed output (#854). +* Fixed issue where `standard_error()` returned `NULL` for objects from + `datawizard::skewness()` and `datawizard::kurtosis()`. + # parameters 0.30.0 ## Changes diff --git a/R/methods_skewness_kurtosis.R b/R/methods_skewness_kurtosis.R index 858cf6dce..53c1a8663 100644 --- a/R/methods_skewness_kurtosis.R +++ b/R/methods_skewness_kurtosis.R @@ -1,8 +1,19 @@ #' @export standard_error.parameters_skewness <- function(model, ...) { - attributes(model)$SE + # datawizard returns SE as column, older objects stored it as attribute + if ("SE" %in% names(model)) { + model$SE + } else { + attributes(model)$SE + } } #' @export standard_error.parameters_kurtosis <- standard_error.parameters_skewness + +#' @export +standard_error.datawizard_skewness <- standard_error.parameters_skewness + +#' @export +standard_error.datawizard_kurtosis <- standard_error.parameters_skewness diff --git a/tests/testthat/test-skewness_kurtosis.R b/tests/testthat/test-skewness_kurtosis.R new file mode 100644 index 000000000..62cd17c72 --- /dev/null +++ b/tests/testthat/test-skewness_kurtosis.R @@ -0,0 +1,25 @@ +skip_if_not_installed("datawizard") + +test_that("standard_error returns the SE column of skewness and kurtosis output", { + out <- datawizard::skewness(mtcars[c("mpg", "cyl", "disp")]) + expect_identical(standard_error(out), out$SE) + out <- datawizard::kurtosis(mtcars$mpg) + expect_identical(standard_error(out), out$SE) +}) + +test_that("standard_error works for the datawizard_* classes", { + s <- datawizard::skewness(mtcars$mpg) + class(s) <- c("datawizard_skewness", "data.frame") + expect_identical(standard_error(s), s$SE) + + k <- datawizard::kurtosis(mtcars$mpg) + class(k) <- c("datawizard_kurtosis", "data.frame") + expect_identical(standard_error(k), k$SE) +}) + +test_that("standard_error reads the SE attribute of old objects", { + s <- 0.67 + attr(s, "SE") <- 0.39 + class(s) <- c("parameters_skewness", "numeric") + expect_identical(standard_error(s), 0.39) +})