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).
Asked
Active
Viewed 3,100 times
8
-
Does `your_package:::your_function` work after loading your package? – jakub Oct 24 '16 at 13:42
-
Yes, it does. However, as I read, it is not suggested to do so @jakub – Rospa Oct 24 '16 at 14:04
-
Indeed. Just checking. Are you defining method for some S3 class? Also, it may be useful to post the roxygen block here. – jakub Oct 24 '16 at 14:20
-
Yes, I am. Do you mean I should post the R script or the NAMESPACE? @jakub – Rospa Oct 24 '16 at 14:38
-
Found the issue. It was a very stupid one. When I wrote the R script there was an additional space before writing the codee. e.g. #' export rather than #' export – Rospa Oct 24 '16 at 14:58
-
2@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 Feb 28 '17 at 16:08
-
[This is a helpful thread](https://stackoverflow.com/questions/42593278/roxygen2-not-creating-rd-documentation). For me, the problem was the unticked box 'roxygenise when install and restart' – tjebo Apr 26 '19 at 14:33
2 Answers
8
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)

PeterVermont
- 1,922
- 23
- 18
-
1Thanks, this helped me too. My impression is that roxygen attempts to interpret ANY appearance of #' and this often messes up @export and other things. – Paul Jul 20 '17 at 17:03
1
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.

Daniel James
- 1,381
- 1
- 10
- 28