Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

When building a package, I got the error

Error in namespaceExport(ns, exports) :    undefined exports: FooBarBaz 

What does this mean, and how do I fix it?

like image 469
Richie Cotton Avatar asked Nov 02 '14 09:11

Richie Cotton


1 Answers

This error occurs when you try to export an object that doesn't exist. That is, the package NAMESPACE file contains the line

export(FooBarBaz) 

but FooBarBaz doesn't exist in the package.


One case where this error can occur is when you are trying to create a common help page for several functions using roxygen2. In the example below, f and g are related functions to be documented in the WidgetUtils page.

#' Widget-related functions #'  #' Utility functions to assist working with widgets. #' @param x An input. #' @return A value. #' @name WidgetUtils #' @export NULL  #' @rdname WidgetUtils #' @export f <- function(x) {   x + 1 }  #' @rdname WidgetUtils #' @export g <- function(x) {   x - 1 } 

The mistake in this code chunk is the inclusion of the @export tag in the WidgetUtils roxygen block. This tells roxygen to generate the export line in the NAMESPACE file, but its value is NULL, so there is nothing to export. By removing the @export line, so the code will work correctly.

like image 54
Richie Cotton Avatar answered Jun 07 '23 11:06

Richie Cotton