Skip to content

Stat smooth+reml #3402

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

Merged
merged 14 commits into from
Jul 9, 2019
Merged

Stat smooth+reml #3402

merged 14 commits into from
Jul 9, 2019

Conversation

ikosmidis
Copy link
Contributor

@ikosmidis ikosmidis commented Jul 8, 2019

Closes issue #2630

@hadley hadley added the tidy-dev-day 🤓 Tidyverse Developer Day label Jul 8, 2019
@hadley
Copy link
Member

hadley commented Jul 8, 2019

Can you please find @gaborcsardi and get him to help you tweak your ESS settings so that it doesn't reformat these files?

@gaborcsardi
Copy link
Member

Can you please find @gaborcsardi and get him to help you tweak your ESS settings so that it doesn't reformat these files?

@ikosmidis I am at the table next to Hadley if you need help. You probably need

(setq-default indent-tabs-mode nil)

For the spaces/indentation, and

(setq ess-indent-with-fancy-comments nil)

to avoid the fancy ess comment character.

R/stat-smooth.r Outdated
if (identical(method, "loess")) {
method.args$span <- span
}

if (is.character(method)) method <- match.fun(method)
## If gam and gam's method is not specified by the user then use REML
if (identical(method, "gam") && is.null(method.args$method)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check should probably be identical(method, mgcv::gam) and happen after the conversion from character to function in the next block.

Copy link
Contributor Author

@ikosmidis ikosmidis Jul 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the design slightly here. In master params$method was replaced by mgcv::gam if it was equal to "gam", within setup_params. Now params$method keeps being "gam" and matching names to functions happens in compute_group. This is to preserve symmetry with how the other methods are handled (e.g. loess) where method is match.funed in compute_group.

The is.character check may as well be redundant but I kept it in just in case I was breaking anything I could not foresee.

Happy to revert to the earlier design and test functions being identical instead of character strings, if this causes any issues; though ggplot2 tests were successful my side.

Copy link
Contributor Author

@ikosmidis ikosmidis Jul 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or perhaps an alternative closer to what you are suggesting, that avoids checking twice if method is "gam" can be something like:

    if (is.character(method)) {
        if (identical(method, "gam")) {
            method <- mgcv::gam
            if (is.null(method.args$method)) {
                method.args$method <- "REML"
            }
        } else {
            method <- match.fun(method)
        }
    }

Again the is.character may not be needed anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK; just figured out that ggplot2 wants the user to be able to supply functions for method as well as character strings so checking method against mgcv::gam after matching makes more sense. Just pushed a fix.

Copy link
Member

@hadley hadley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking much better, thanks!

@hadley hadley merged commit a339a18 into tidyverse:master Jul 9, 2019
@hadley
Copy link
Member

hadley commented Jul 9, 2019

Thanks @ikosmidis!

@lock
Copy link

lock bot commented Jan 5, 2020

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Jan 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
tidy-dev-day 🤓 Tidyverse Developer Day
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants