-
Notifications
You must be signed in to change notification settings - Fork 2.1k
default formula argument to NULL in geom_smooth() #3307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
508e1bc
4bb34e3
04b3327
bf963db
c4ce320
c9644c3
0c2826b
5910606
99e9ad2
68e8a30
b4d92e7
3aaa53e
ca5ba90
6a97cd6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,9 @@ | |
#' model that `method = "auto"` would use, then set | ||
#' `method = "gam", formula = y ~ s(x, bs = "cs")`. | ||
#' @param formula Formula to use in smoothing function, eg. `y ~ x`, | ||
#' `y ~ poly(x, 2)`, `y ~ log(x)` | ||
#' `y ~ poly(x, 2)`, `y ~ log(x)`. `NULL` by default, in which case | ||
#' `method = "auto"` implies `formula = y ~ x` when there are fewer than 1,000 | ||
#' observations and `formula = y ~ s(x, bs = "cs")` otherwise. | ||
#' @param se Display confidence interval around smooth? (`TRUE` by default, see | ||
#' `level` to control.) | ||
#' @param fullrange Should the fit span the full range of the plot, or just | ||
|
@@ -38,7 +40,7 @@ stat_smooth <- function(mapping = NULL, data = NULL, | |
geom = "smooth", position = "identity", | ||
..., | ||
method = "auto", | ||
formula = y ~ x, | ||
formula = NULL, | ||
se = TRUE, | ||
n = 80, | ||
span = 0.75, | ||
|
@@ -86,21 +88,25 @@ StatSmooth <- ggproto("StatSmooth", Stat, | |
|
||
if (max_group < 1000) { | ||
params$method <- "loess" | ||
params$formula <- params$formula %||% (y ~ x) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're now setting the formula in two places — I don't think you need to set when figuring out which There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the formula isn't set before the message() call just below, then the message could include a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I see the problem — now that |
||
} else { | ||
params$method <- "gam" | ||
params$formula <- y ~ s(x, bs = "cs") | ||
params$formula <- params$formula %||% (y ~ s(x, bs = "cs")) | ||
} | ||
message("`geom_smooth()` using method = '", params$method, | ||
"' and formula '", deparse(params$formula), "'") | ||
} | ||
if (identical(params$method, "gam")) { | ||
params$method <- mgcv::gam | ||
params$formula <- params$formula %||% (y ~ s(x, bs = "cs")) | ||
} else { | ||
params$formula <- params$formula %||% (y ~ x) | ||
} | ||
|
||
params | ||
}, | ||
|
||
compute_group = function(data, scales, method = "auto", formula = y~x, | ||
compute_group = function(data, scales, method = "auto", formula = NULL, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably have |
||
se = TRUE, n = 80, span = 0.75, fullrange = FALSE, | ||
xseq = NULL, level = 0.95, method.args = list(), | ||
na.rm = FALSE) { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.