Skip to content

Commit b316892

Browse files
committed
Correctly load mgcv package whenever method='gam'
1 parent dc52642 commit b316892

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

R/stat-smooth.r

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ StatSmooth <- proto(Stat, {
129129
' so using loess.',
130130
' Use \'method = x\' to change the smoothing method.')
131131
} else {
132-
try_require("mgcv")
133132
method <- "gam"
134133
formula <- y ~ s(x, bs = "cs")
135134
message('geom_smooth: method="auto" and size of largest group is >=1000,',
@@ -138,6 +137,8 @@ StatSmooth <- proto(Stat, {
138137
}
139138
}
140139

140+
if (method == "gam") try_require("mgcv")
141+
141142
.super$calculate_groups(., data, scales, method = method, formula = formula, ...)
142143
}
143144

0 commit comments

Comments
 (0)