Skip to content

Commit 7b62271

Browse files
authored
Move {MASS} to Suggests (#5993)
* add `check_installed("MASS")` where appropriate * pre-populate parameters * move MASS * conditionally skip that that require MASS * fence in example * Revert "fence in example" This reverts commit 93295f5. * fence-in correct piece this time * sneak in forgotten news bullet
1 parent 926f290 commit 7b62271

File tree

8 files changed

+28
-5
lines changed

8 files changed

+28
-5
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ Imports:
3838
gtable (>= 0.1.1),
3939
isoband,
4040
lifecycle (> 1.0.1),
41-
MASS,
4241
rlang (>= 1.1.0),
4342
scales (>= 1.3.0),
4443
stats,
@@ -53,6 +52,7 @@ Suggests:
5352
knitr,
5453
mapproj,
5554
maps,
55+
MASS,
5656
mgcv,
5757
multcomp,
5858
munsell,

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# ggplot2 (development version)
22

3+
* `geom_errorbarh()` is deprecated in favour of
4+
`geom_errorbar(orientation = "y")` (@teunbrand, #5961).
35
* `geom_contour()` should be able to recognise a rotated grid of points
46
(@teunbrand, #4320)
57
* `geom_boxplot()` gains additional arguments to style the colour, linetype and

R/stat-density-2d.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ StatDensity2d <- ggproto("StatDensity2d", Stat,
138138
contour_type = "lines",
139139

140140
compute_layer = function(self, data, params, layout) {
141+
check_installed("MASS", reason = "for calculating 2D density.")
141142
# first run the regular layer calculation to infer densities
142143
data <- ggproto_parent(Stat, self)$compute_layer(data, params, layout)
143144

R/stat-ellipse.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ stat_ellipse <- function(mapping = NULL, data = NULL,
7777
StatEllipse <- ggproto("StatEllipse", Stat,
7878
required_aes = c("x", "y"),
7979

80+
setup_params = function(data, params) {
81+
params$type <- params$type %||% "t"
82+
if (identical(params$type, "t")) {
83+
check_installed("MASS", "for calculating ellipses with `type = \"t\"`.")
84+
}
85+
params
86+
},
87+
8088
compute_group = function(data, scales, type = "t", level = 0.95,
8189
segments = 51, na.rm = FALSE) {
8290
calculate_ellipse(data = data, vars = c("x", "y"), type = type,

R/stat-qq.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@
3232
#' p <- ggplot(df, aes(sample = y))
3333
#' p + stat_qq() + stat_qq_line()
3434
#'
35-
#' # Use fitdistr from MASS to estimate distribution params
36-
#' params <- as.list(MASS::fitdistr(df$y, "t")$estimate)
35+
#' # Use fitdistr from MASS to estimate distribution params:
36+
#' # if (requireNamespace("MASS", quietly = TRUE)) {
37+
#' # params <- as.list(MASS::fitdistr(df$y, "t")$estimate)
38+
#' # }
39+
#' # Here, we use pre-computed params
40+
#' params <- list(m = -0.02505057194115, s = 1.122568610124, df = 6.63842653897)
3741
#' ggplot(df, aes(sample = y)) +
3842
#' stat_qq(distribution = qt, dparams = params["df"]) +
3943
#' stat_qq_line(distribution = qt, dparams = params["df"])

man/geom_qq.Rd

Lines changed: 6 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-stat-density2d.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
skip_if_not_installed("MASS")
2+
13
test_that("uses scale limits, not data limits", {
24
base <- ggplot(mtcars, aes(wt, mpg)) +
35
stat_density_2d() +

tests/testthat/test-stat-ellipsis.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
skip_if_not_installed("MASS")
2+
13
test_that("stat_ellipsis returns correct data format", {
24
n_seg <- 40
35
d <- data_frame(x = c(1, 1, 4, 4, 4, 3, 3, 1), y = c(1:4, 1:4), id = rep(1:2, each = 4))

0 commit comments

Comments
 (0)