Skip to content
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

Improve specification of dependencies #25

Open
ailich opened this issue Jul 11, 2023 · 2 comments
Open

Improve specification of dependencies #25

ailich opened this issue Jul 11, 2023 · 2 comments

Comments

@ailich
Copy link

ailich commented Jul 11, 2023

Currently if you don't load tidyverse, then an error will be produced. It'd be worth adding import/importFrom tags to your functions to specify which external functions are needed and listing ggplot2 under the "Depends" field of the description. Setting it up this way would automatically load ggplot2 if the user loads ggbump, and the various tidyverse functions could be called from within your functions without making the user call it.

library(ggplot2)
library(ggbump)
#> Warning: package 'ggbump' was built under R version 4.3.1

df<- data.frame(x=1:10, y =rnorm(10))

ggplot(df, mapping = aes(x=x, y=y))+
  geom_point()+
  geom_bump()
#> Warning: Computation failed in `stat_bump()`
#> Caused by error in `arrange()`:
#> ! could not find function "arrange"

Created on 2023-07-11 with reprex v2.0.2

@ailich
Copy link
Author

ailich commented Jul 11, 2023

Oh, actually, I'm not seeing this issue with the development version from github, but it's still better practice to specify the imports in the function though rather than only using the :: since it'll automatically add the your imports to the NAMESPACE file. I put in a pull request for the changes. Since you use dplyr pretty extensively I imported that whole package for each function that used it, but you could set it to import only the functions you're using.

library(ggbump)
#> Loading required package: ggplot2

df<- data.frame(x=1:10, y =rnorm(10))

ggplot(df, mapping = aes(x=x, y=y))+
  geom_point()+
  geom_bump()

Created on 2023-07-11 with reprex v2.0.2

@teunbrand
Copy link
Contributor

Just commenting here that I also ran into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants