Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R CMD check fails with "undefined exports"

I'm trying to create an R package but I keep getting the error:

Error in namespaceExport(ns, exports) : 
  undefined exports: MCLE, defineFunctions, naiveMLE

when running R CMD check on my package. I'm using roxygen2, and the three functions listed in the error message are the three with @export tags. I've checked similar problems/solutions on stack overflow:

  • R: Error in namespaceExport(ns, exports) : undefined exports:

  • Error in namespaceExport(ns, exports) : undefined exports: ... Error: package or namespace load failed

  • What does "Error in namespaceExport(ns, exports) : undefined exports" mean?

but none of these seem to resolve my problem (I'm not using <<-, I don't export any functions with a common help page, and the issue isn't with ggplot2 or a different R package on CRAN).

I've built the package after deleting the NAMESPACE file, and it built successfully. I've also confirmed that the package has the functions listed as "undefined," and I don't know what else to check!

like image 448
random_forest_fanatic Avatar asked Feb 16 '16 05:02

random_forest_fanatic


1 Answers

I had a very similar problem. Did you check your .Rbuildignore file? It could be related to regular expression matches with the functions you want to export.

I was trying to exclude from the build the directory "HTLM_downloads" by putting the name inside .Rbuildignore. Unfortunately this does not work since it ignores every file containing the word "html" (HTML). Not even an @export solved the problem. I needed to anchor the expression by putting ^HTML_downloads$.

You can easily exclude files and/or directory by using devtools::use_build_ignore("file/dir you want to ignore").

Hope this helped

I'd like to thank @hadley for his kind and neat support

like image 94
Francesco Grossetti Avatar answered Nov 05 '22 17:11

Francesco Grossetti