I was getting this error when running devtools::document
but had no idea how to troubleshoot. The file that popped up on my installed package when I entered ?MyPackage-package
did not match the text in MyPackage-package.R
at all. I initially suspected it might have been from adding the awesome citation functionality from RDpack
, but this was not the culprit. How did I go about ultimately fixing the problem?
Asked
Active
Viewed 766 times
0

Michael Roswell
- 1,300
- 12
- 31
-
The first thing I'd check is that the title lines of each of your functions are properly formatted. This is not obviously connected to Rdpack -- have you tried removing RdMacros and redocumenting? Could title lines contain characters that Rdpack is misinterpreting? – Martin Smith Aug 27 '20 at 15:57
-
Are you sure this message is from 'R CMD check'? It doesn't write NAMESPACE. It looks like a message from devtools. If you haven't resolved this yet, a link to your package would enable concrete help. – Georgi Boshnakov Oct 10 '20 at 19:33
-
@Georgi Boshnakov, thanks for this. I'll do a bit more troubleshooting/cleanup and then if still stuck I'll link to the package. – Michael Roswell Oct 12 '20 at 16:02
-
@GeorgiBoshnakov, looks like I tracked down the issue at last. Does this make sense to you? – Michael Roswell Dec 23 '20 at 14:38
1 Answers
1
The error resulted from incorrect formatting in my PackageName-package.R
file.
I had heavily edited the file created by usethis::use_package_doc()
, and added all of my roxygen comments Below the default content added by usethis
. After looking at the documentation for merTools
, I saw that it was ok to have the stuff I understand to be important for roxygen2
to make the .Rd files after and not before all the other roxygen comments.
After moving the stuff created by usethis::use_package_doc()
(and not just the NULL
line; that was already at the end) to the bottom of the .R file, everything seemed to render fine and this error disappeared.

Michael Roswell
- 1,300
- 12
- 31
-
Late response, I missed your answer at the time. Adding this comment to add more context for future visitors. ``` – Georgi Boshnakov Jan 01 '22 at 22:18
-
Sorry, the above comment was published prematurely, I didn't realise that pressing 'Enter' publishes the comment. I missed your answer at the time. I use `usethis` package and it is great for helping with arcane stuff but I find the file created by `usethis::use_package_doc()` (which I just checked) not very helpful without referring to the roxygen2 documentation. I personally start off with a file from some other package, as you did above. – Georgi Boshnakov Jan 01 '22 at 22:31