AU-BCE-EE / ABM

R model for anaerobic microbial degradation of organic matter with multiple microbial groups
1 stars 2 forks source link

Need to load other packages when calling library(ABM) #21

Closed fdalby closed 2 months ago

fdalby commented 1 year ago

We need both deSolve and dplyr to be loaded when we load the ABM package. How can this be done automatically?

sashahafner commented 1 year ago
  1. Include the packages in DESCRIPTION in Imports: (or Depends:)

2a. Call each function with :: e.g. deSolve::lsoda() or 2b. Include package in import() in NAMESPACE, and then we can call each function without the packagename:: prefix.

2a is supposed to be safer.

Do we really need dplyr? I have come to dislike the tidyverse packages and tibbles (perhaps not a good reason), and dplyr has a lot of dependencies (see Imports: here: https://cran.r-project.org/web/packages/dplyr/index.html) which means if there is a problem in any one of those packages or one of their dependencies, there is suddenly a problem with ABM. tidyverse functions do seem less stable than others to me (one reason I stopped using it). See this summary for concerns about too many dependencies: https://www.tinyverse.org/.

I'll see if I can find the relevant code. Alternatives are to use a little more code with base R or perhaps data.table, which has its own significant advantages, along with some disadvantages in my opinion (at least some changes to indexing syntax).

sashahafner commented 1 year ago

From discussion today, issue is speed, with rbind() being too slow. I will look into alternatives, first considering base R options (if we can find something fast), then maybe data.table.

sashahafner commented 11 months ago

Seems like some dplyr function may be used somewhere in the function definitions somewhere from the warning from R CMD check ...

* checking dependencies in R code ... WARNING
'::' or ':::' import not declared from: ‘dplyr’
fdalby commented 11 months ago

Yes. That is bind_rows which is much fast than rbind I found. It is in abm_variable and abm_regular

sashahafner commented 11 months ago

Ah, OK. From comment just above it looks like I promised to look into alternatives only about 5 months ago! Will check it out, but it seems we need to import something then. I like the difference in the imports lines for data.table versus dplyr:

https://cran.r-project.org/web/packages/dplyr/index.html https://cran.r-project.org/web/packages/data.table/index.html

sashahafner commented 11 months ago

data.table solution didn't work as easily as I had expected. Might check it out later, but as of 235abeae3930b8c63d2cab0e115385b60deeae3f or so, there is Import: dplyr in DESCRIPTION. Is that the correct statement when we only use one function? I always lose track of these details.

fdalby commented 2 months ago

packages loaded. Works fine and I am closing