R github package w/ devtools: warning unknown macro '\item'
For me, this was happening when I was using \n
in the description of a function in a library I was writing (I was describing what that backslash "n" escape sequence meant. I fixed it by escaping the escape sequence itself in the function's .Rd
file. Example:
BAD/ERRORED:
\description{
Blah blah and `\n` is an example of blah blah blah
}
FIXED/SOLUTION:
\description{
Blah blah and `\\n` is an example of blah blah blah
}
For me the issue was using "%" sign in the text. When I removed it or escaped it ("\%"), it no longer threw an error. If you open the roxygen generated .Rd file in the editor, it can give you a hint, for me the text after the % was coloured differently.
You can use RStudio to help on package development in several aspects:
use build & load tool in build panel for package project. You can build, update documents (you may want to check more options in setting about Roxygen2, some are not turned on by default), load package in one click. The error you met should be found earlier, and you don't need to manually install to test.
use the preview feature for .Rd file
Another method is to compare the working and non-working version source file, .Rd file to find the difference.
Generally direct editing of generated file should be avoided.
To make this answer more complete, here are tips from @Benjamin about formatting in Rd files:
It may be the & in lines like "Import with (e.g.) read.csv & specify" although I'm not entirely sure. I recall some of the punctuation being problematic, especially %. Changing & to and might be worth a shot
N.B. Changing %
to \%
in the .Rd
documentation file, or the underlying roxygen comment, should prevent issues relating to use of the % symbol. This is due to the use of LaTeX.
From @Thomas:
Can also come up if you have a stray { somewhere