Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

roxygen2: function not exported to NAMESPACE even after using @export

Tags:

r

roxygen2

I am building a package and get an error, saying that a function is not an exported object of the package. In the R script, I have used @export tag to export the function, however when I roxigenise using document() or roxygen() the function is not exported to the NAMESPACE (the Rmd file for that function is created though).

like image 547
Rospa Avatar asked Oct 24 '16 13:10

Rospa


2 Answers

I had a similar problem. It turned out that inside my function I had commented out a line that began with an apostrophe (in front of 'Battlestar Galactica' in my fake example) so it look like this:

#' @export
getMyFavoriteSciFiShows <- function() {
  myFavoriteSciFiShows <-
    c('Star Trek Next Generation',
      #'Battlestar Galactica',
      'Babylon 5')
  return(myFavoriteSciFiShows)
}

This really screwed up roxygen2 v 6.0.1 since it did not signal any errors and this is what it put into my NAMSEPACE file:

export("Galactica',")
export(Battlestar)
like image 173
PeterVermont Avatar answered Nov 15 '22 02:11

PeterVermont


It happened to me then I ran

devtools::document()

and click check from the Build tab the problem got solved.

I am giving this answer to someone who may have this same problem and search for this. It may help.

like image 30
Daniel James Avatar answered Nov 15 '22 00:11

Daniel James