Skip to content

stat_ellipse() in ggplot2 4.0.0 breaks R CMD check tests #6578

@nanxstats

Description

@nanxstats

I found a problem with stat_ellipse() in ggplot2 4.0.0 that causes R CMD check to fail when running tests that use stat_ellipse(). This issue does not occur in ggplot2 3.5.2 and earlier versions.

Reprex

Install ggplot2 4.0.0 RC and create a minimal package:

devtools::install_github("tidyverse/ggplot2@rc/4.0.0")
usethis::create_package("zzz")

In the new package, add dependencies and create a function:

usethis::use_package("ggplot2")
usethis::use_package("vdiffr", type = "Suggests")
usethis::use_r("f")

Add a function that uses stat_ellipse():

f <- function () {
  ggplot2::ggplot(faithful, ggplot2::aes(waiting, eruptions)) +
    ggplot2::geom_point() +
    ggplot2::stat_ellipse()
}

Add a snapshot test:

usethis::use_testthat()
usethis::use_test("f")
testthat::test_that("stat_ellipse works", {
  x <- f()
  vdiffr::expect_doppelganger("call stat_ellipse", x)
})

Run tests to generate the snapshot:

devtools::test()

Run R CMD check --as-cran:

R CMD build zzz
R CMD check zzz_0.0.0.9000.tar.gz --as-cran

The check fails with:

* checking tests ...
  Running ‘testthat.R’
 ERROR
Running the tests in ‘tests/testthat.R’ failed.
Last 13 lines of output:
   1.  │           └─ggplot2 (local) f(l = layers[[i]], d = data[[i]])
   2.  │             └─l$compute_statistic(d, layout)
   3.  │               └─ggplot2 (local) compute_statistic(..., self = self)
   4.  │                 └─self$stat$setup_params(data, self$stat_params)
   5.  │                   └─ggplot2 (local) setup_params(...)
   6.  │                     └─rlang::check_installed("MASS", "for calculating ellipses with `type = \"t\"`.")
   7.  │                       └─base::stop(cnd)
   8.  └─rlang (local) `<fn>`(`<S3: rlib_error_package_not_found>`)
   9.    └─handlers[[1L]](cnd)
   10.     └─cli::cli_abort(...)
   11.       └─rlang::abort(...)

  [ FAIL 1 | WARN 0 | SKIP 0 | PASS 0 ]
  Error: Test failures
  Execution halted

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions