diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION index 4486e9c95..703fd4180 100644 --- a/CRAN-SUBMISSION +++ b/CRAN-SUBMISSION @@ -1,3 +1,3 @@ -Version: 0.19.11 -Date: 2024-05-12 17:57:07 UTC -SHA: b850f730c05480293504a2b81217d9244de20f3e +Version: 0.20.0 +Date: 2024-06-03 12:54:55 UTC +SHA: 40c4fbce021ca275d823719e60f74717ff61f33d diff --git a/DESCRIPTION b/DESCRIPTION index 8f4a23d7a..687d1ef55 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: insight Title: Easy Access to Model Information for Various Model Objects -Version: 0.19.11.5 +Version: 0.20.0 Authors@R: c(person(given = "Daniel", family = "Lüdecke", diff --git a/NEWS.md b/NEWS.md index 6cc1920b3..19bddd4bc 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# insight 0.19.12 +# insight 0.20.0 ## Breaking @@ -10,6 +10,13 @@ * `get_datagrid()` * `print_parameters()` +## Bug fixes + +* Fixed errors in CRAN checks. + +* Fixed issues in `compact_list()` for objects that contained variables of + class `vctrs`. + # insight 0.19.11 ## General @@ -19,7 +26,7 @@ ## Bug fixes -* Fixed issue with `get_data()` for `coxme` models when `source`was set to +* Fixed issue with `get_data()` for `coxme` models when `source` was set to `"modelframe"`. # insight 0.19.10 diff --git a/R/get_response.R b/R/get_response.R index a6ddfcee9..2e6a0e0db 100644 --- a/R/get_response.R +++ b/R/get_response.R @@ -75,6 +75,11 @@ get_response.default <- function(x, select = NULL, as_proportion = TRUE, source !is.matrix(response)) { response <- as.vector(response) } + + # clear vctr-class attributes + if (inherits(response, "vctrs_vctr")) { + class(response) <- setdiff(class(response), c("haven_labelled", "vctrs_vctr")) + } response } diff --git a/R/utils_compact.R b/R/utils_compact.R index 724b72672..19f5562c8 100644 --- a/R/utils_compact.R +++ b/R/utils_compact.R @@ -9,6 +9,13 @@ #' compact_list(c(1, NA, NA), remove_na = TRUE) #' @export compact_list <- function(x, remove_na = FALSE) { + # remove vctr-class attributes + if (is.data.frame(x)) { + x[] <- lapply(x, function(i) { + class(i) <- setdiff(class(i), c("haven_labelled", "vctrs_vctr")) + i + }) + } if (remove_na) { x[!sapply(x, function(i) !is_model(i) && !inherits(i, c("Formula", "gFormula")) && (length(i) == 0L || is.null(i) || (length(i) == 1L && is.na(i)) || all(is.na(i)) || any(i == "NULL", na.rm = TRUE)))] } else { @@ -30,5 +37,5 @@ compact_list <- function(x, remove_na = FALSE) { #' #' @export compact_character <- function(x) { - x[!sapply(x, function(i) nchar(i) == 0 || all(is.na(i)) || any(i == "NULL", na.rm = TRUE))] + x[!sapply(x, function(i) !nzchar(i, keepNA = TRUE) || all(is.na(i)) || any(i == "NULL", na.rm = TRUE))] } diff --git a/cran-comments.md b/cran-comments.md index 987c7ad06..8ff8b0606 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1 +1,9 @@ -This release is required for the planned update of the 'parameters' package, which will be released once 'insight' is on CRAN. The 'parameters' update fixes errors in CRAN checks. +This release fixes errors in CRAN checks. + +Additionally, in the process of stabilizing the API/user interface for packages +from the 'easystats' project, some argument names were renamed and old names +have been deprecated. This will *not break* downstream dependent packages, however, +reverse-dependency checks will raise warnings. We have already patched all +affected downstream packages and will submit them to CRAN in the next few days, +after the release of 'insight'. Once this release-cycle is complete, all +warnings due to deprecated argument names should be resolved. \ No newline at end of file diff --git a/tests/testthat/test-compact-list.R b/tests/testthat/test-compact-list.R index a8a009613..6867c6fed 100644 --- a/tests/testthat/test-compact-list.R +++ b/tests/testthat/test-compact-list.R @@ -1,19 +1,27 @@ test_that("compact_list works as expected", { - expect_equal(compact_list(list(NULL, 1, c(NA, NA))), list(1, c(NA, NA))) - expect_equal(compact_list(c(1, NA, NA)), c(1, NA, NA)) - expect_equal(compact_list(list(NULL, 1, list(NULL, NULL))), list(1)) - expect_equal(compact_list(c(1, NA, NA), remove_na = TRUE), 1) - expect_equal(compact_list(c(1, 2, 3), remove_na = TRUE), c(1, 2, 3)) - expect_equal(compact_list(""), "") + expect_identical(compact_list(list(NULL, 1, c(NA, NA))), list(1, c(NA, NA))) + expect_identical(compact_list(c(1, NA, NA)), c(1, NA, NA)) + expect_identical(compact_list(list(NULL, 1, list(NULL, NULL))), list(1)) + expect_identical(compact_list(c(1, NA, NA), remove_na = TRUE), 1) + expect_identical(compact_list(c(1, 2, 3), remove_na = TRUE), c(1, 2, 3)) + expect_identical(compact_list(""), "") expect_null(compact_list(NULL)) - expect_equal(compact_list(logical(0)), logical(0)) + expect_identical(compact_list(logical(0)), logical(0)) }) test_that("compact_list, logical > 1", { x <- list(a = 1, b = c(1, 2), c = NA) - expect_equal(compact_list(x, remove_na = TRUE), list(a = 1, b = c(1, 2))) - expect_equal(compact_list(x, remove_na = FALSE), list(a = 1, b = c(1, 2), c = NA)) + expect_identical(compact_list(x, remove_na = TRUE), list(a = 1, b = c(1, 2))) + expect_identical(compact_list(x, remove_na = FALSE), list(a = 1, b = c(1, 2), c = NA)) x <- list(a = 1, b = c(NA, NA), c = NA) - expect_equal(compact_list(x, remove_na = TRUE), list(a = 1)) - expect_equal(compact_list(x, remove_na = FALSE), list(a = 1, b = c(NA, NA), c = NA)) + expect_identical(compact_list(x, remove_na = TRUE), list(a = 1)) + expect_identical(compact_list(x, remove_na = FALSE), list(a = 1, b = c(NA, NA), c = NA)) +}) + +test_that("compact_list, vctrs", { + data(mtcars) + class(mtcars$mpg) <- c("haven_labelled", "vctrs_vctr", "double") + attr(mtcars$mpg, "labels") <- c(`21` = 21) + out <- compact_list(mtcars) + expect_true(all(vapply(out, class, character(1)) == "numeric")) }) diff --git a/tests/testthat/test-fixest.R b/tests/testthat/test-fixest.R index 4bf6cb0a8..43642b748 100644 --- a/tests/testthat/test-fixest.R +++ b/tests/testthat/test-fixest.R @@ -1,3 +1,4 @@ +# Currently doesn't work on devel - potential fixest issue? skip_if(TRUE) skip_on_os("mac")