Skip to content

Commit 9e1cae9

Browse files
committed
add check_installed("MASS") where appropriate
1 parent fb33e26 commit 9e1cae9

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

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,

0 commit comments

Comments
 (0)