gauravsk / ranacapa

R package for downstream analysis for anacapa eDNA pipeline
https://f1000research.com/articles/7-1734/v1
GNU General Public License v3.0
22 stars 11 forks source link

It might be worth redoing how we manage package imports #23

Closed gauravsk closed 6 years ago

gauravsk commented 6 years ago

Hadley Wickham suggests using the package::function() syntax when writing code:

Adding a package dependency here ensures that it’ll be installed. However, it does not mean that it will be attached along with your package (i.e., library(x)). The best practice is to explicitly refer to external functions using the syntax package::function(). This makes it very easy to identify which functions live outside of your package. This is especially useful when you read your code in the future.

If you use a lot of functions from other packages this is rather verbose. There’s also a minor performance penalty associated with :: (on the order of 5µs, so it will only matter if you call the function millions of times). You’ll learn about alternative ways to call functions in other packages in namespace imports.

Some more info about this here

It probably doesn't matter a whole lot, but might be worth it to make code more readable I guess

madcowen commented 6 years ago

I did this for the R scripts and not the shiny app, and haven't changed NAMESPACE yet. Do we need to do this for the shiny app even though the packages are loaded (e.g. library("ggplot2")) in both server.R and ui.R? Using this syntax doesn't look too bad, except ggplot calls are a little ugly, and I imagine many of the shiny app functions will look strange. I could use this syntax for all packages except for shiny?

gauravsk commented 6 years ago

I think this is done, thanks @madcowen !