I am developing an R package and testthat library is applied for verification. The error issue happens when loading function from external Mclust package (https://cran.r-project.org/web/packages/mclust/index.html) that includes anonymous function inside. This function is not recognised by using requireNamespace(). Here is code example:
get.enr.bg.normfit <- function(x) {
result <- c(NA, NA)
if (requireNamespace("mclust")) {
names(result) <- c("mean","sd")
# fit two normal distributions to data
# model <- Mclust(na.omit(x), G=2, modelNames="V")
model <- mclust::Mclust(na.omit(x), G=2)
...
The test runs, but can not find additional mclust function inside:
Error: transcritpt type missing mark (@test-expr-filter.R#53) --------------- could not find function "mclustBIC
The problem that Mclust calls mclustBIC from anonymous function inside. The same issue occurs when running full package check in RStudio.
Loading required namespace: mclust Error in eval(expr, envir, enclos) : could not find function "mclustBIC" Calls: filterGeneExpr -> get.enr.bg.normfit -> -> eval -> eval
Is there any strategy to fix this? I can also fully depend on the package mclust, but this function is optional therefore it makes sense only to use require option.