6
votes

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).

2
Does your_package:::your_function work after loading your package?jakub
Yes, it does. However, as I read, it is not suggested to do so @jakubRospa
Indeed. Just checking. Are you defining method for some S3 class? Also, it may be useful to post the roxygen block here.jakub
Yes, I am. Do you mean I should post the R script or the NAMESPACE? @jakubRospa
@Rospa your comment is confusing as it does not include the @ symbol before export and your comparison looks identical (both have one space). Perhaps this was because of the markdown formatting.PeterVermont

2 Answers

6
votes

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)
0
votes

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.