Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spurious(?) viewport-too-small error with new ggplot2 version 3.5.0 #694

Merged
merged 6 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: performance
Title: Assessment of Regression Models Performance
Version: 0.10.9.3
Version: 0.10.9.4
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
Expand Down
15 changes: 8 additions & 7 deletions R/helpers.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# small wrapper around this commonly used try-catch
.safe <- function(code, on_error = NULL) {
tryCatch(code, error = function(e) on_error)
if (getOption("easystats_erros", FALSE) && is.null(on_error)) {
code
} else {
tryCatch(code, error = function(e) on_error)
}
}


Expand Down Expand Up @@ -34,13 +38,10 @@
if (!is.numeric(x)) {
return(x)
}

# remove missings
tmp <- x[!is.na(x)]

# standardize
tmp <- (tmp - mean(tmp)) / stats::sd(tmp)

# and fill in values in original vector
x[!is.na(x)] <- tmp

Expand All @@ -65,10 +66,10 @@

.get_sigma <- function(model, verbose = TRUE) {
s <- insight::get_sigma(model, ci = NULL, verbose = verbose)
if (!is.null(s)) {
as.numeric(s)
} else {
if (is.null(s)) {
NULL
} else {
as.numeric(s)
}
}

Expand Down
14 changes: 14 additions & 0 deletions tests/testthat/test-helpers.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
skip_on_cran()
skip_if_not_installed("withr")
withr::with_options(
list(easystats_erros = TRUE),
test_that(".safe works with options", {
expect_error(performance:::.safe(mean(fd)), regex = "object 'fd' not found")
expect_identical(performance:::.safe(mean(fd), 1L), 1L)
expect_identical(performance:::.safe(mean(c(1, 2, 3))), 2)
})
)
test_that(".safe works", {
expect_null(performance:::.safe(mean(fd)))
expect_identical(performance:::.safe(mean(c(1, 2, 3))), 2)
})
2 changes: 2 additions & 0 deletions tests/testthat/test-r2_nagelkerke.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ test_that("r2_nagelkerke", {
expect_equal(r2(model), list(R2_Tjur = c(`Tjur's R2` = 0.477692621360749)), tolerance = 1e-3, ignore_attr = TRUE)
})

skip_if_not_installed("withr")

test_that("r2_nagelkerke", {
skip_if_not_installed("MASS")
withr::with_options(
Expand Down
Loading