Skip to content

Commit dd3b594

Browse files
committed
Revert "fallback to method = "lm" in absence of {mgcv}"
This reverts commit 5824b1d.
1 parent 978129c commit dd3b594

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

R/stat-smooth.R

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ StatSmooth <- ggproto("StatSmooth", Stat,
111111
}
112112

113113
if (is.null(params$formula)) {
114-
if (identical(method, "gam") && is_installed("mgcv")) {
114+
if (identical(method, "gam")) {
115115
params$formula <- y ~ s(x, bs = "cs")
116116
} else {
117117
params$formula <- y ~ x
@@ -133,15 +133,7 @@ StatSmooth <- ggproto("StatSmooth", Stat,
133133
}
134134
# If gam and gam's method is not specified by the user then use REML
135135
if (identical(method, gam_method())) {
136-
if (identical(method, stats::lm)) {
137-
cli::cli_warn(c(
138-
"The {.pkg mgcv} package must be installed to use \\
139-
{.code method = \"gam\"}.",
140-
"Falling back to {.code method = \"lm\"}."
141-
))
142-
} else {
143-
params$method.args$method <- params$method.args$method %||% "REML"
144-
}
136+
params$method.args$method <- params$method.args$method %||% "REML"
145137
}
146138

147139
if (length(msg) > 0) {
@@ -212,10 +204,4 @@ StatSmooth <- ggproto("StatSmooth", Stat,
212204
)
213205

214206
# This function exists to silence an undeclared import warning
215-
gam_method <- function() {
216-
if (is_installed("mgcv")) {
217-
mgcv::gam
218-
} else {
219-
stats::lm
220-
}
221-
}
207+
gam_method <- function() mgcv::gam

0 commit comments

Comments
 (0)