Skip to content

Name conflict causes stat_smooth to fail when method = "auto" #2535

Closed

Description

@kylebaron

The function s in the formula y ~ s(x, bs = "cs") is (I believe) mgcv::s, but that function isn't imported (mgcv is a Suggests). The way this is set up, when there is a namespace conflict, no warning is issued (as expected) and stat_smooth fails.

s <- function(...) "A"

library(ggplot2)

data(diamonds)

myplot <- ggplot(diamonds, aes(carat,price)) + geom_smooth()

myplot
#> `geom_smooth()` using method = 'gam'
#> Warning: Computation failed in `stat_smooth()`:
#> $ operator is invalid for atomic vectors

rm(s)

myplot
#> `geom_smooth()` using method = 'gam'

s <- mgcv::s

myplot
#> `geom_smooth()` using method = 'gam'

Created on 2018-04-18 by the reprex package (v0.2.0).

Activity

  1. added
    feature
    good first issue ❤️
    help wanted ❤️
    on Apr 27, 2018
  2. lock commented on Oct 28, 2018

    @lock

    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/

  3. locked and limited conversation to collaborators on Oct 28, 2018
  4. added a commit that references this issue on Apr 1, 2026
    62e0f86
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featuregood first issue ❤️help wanted ❤️layers 📈

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions