Skip to content

geom_smooth doesn't work when function is entered with :: #2870

Closed
@IndrajeetPatil

Description

@IndrajeetPatil
# loading needed libraries
library(ggplot2)
library(mgcv)
#> Loading required package: nlme
#> This is mgcv 1.8-24. For overview type 'help("mgcv-package")'.

# without `::`
ggplot(mtcars, aes(wt, mpg)) +
  geom_point() +
  geom_smooth(method = "gam", formula = y ~ s(x, k = 3))

# with `::`
ggplot(mtcars, aes(wt, mpg)) +
  geom_point() +
  geom_smooth(method = "gam", formula = y ~ mgcv::s(x, k = 3))
#> Warning: Computation failed in `stat_smooth()`:
#> invalid type (list) for variable 'mgcv::s(x, k = 3)'

# this indeed a function from `mgcv package`
args(mgcv::s)
#> function (..., k = -1, fx = FALSE, bs = "tp", m = NA, by = NA, 
#>     xt = NULL, id = NULL, sp = NULL, pc = NULL) 
#> NULL

Created on 2018-08-28 by the reprex package (v0.2.0.9000).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions