Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unexpected section header '\examples' when checking R package

Tags:

package

r

When I use R CMD check pkg_name to check my own R package, I obtain warnings like this:

unexpected section header '\examples'
unexpected section header '\keyword'

The problem exists in the .Rd file where I write some example R codes for my own data (i.e. the .Rd file is for a .RDdata file, not for an .R function file). I was thinking that we can just write example codes ("...") between the {} below:

\example{
...
}

Unfortunately it cannot pass the package checking procedure...Thanks in advance for your help!

like image 452
alittleboy Avatar asked Aug 07 '12 19:08

alittleboy


3 Answers

I once experienced this problem when using the percentage symbol (%). I was trying to write documentation for a confidence interval parameter. I then realised that I needed to escape the symbol with a backslash to resolve the error (just like in LaTeX). Thus, I replaced % with \%. This fixed the error.

like image 136
Jeromy Anglim Avatar answered Oct 30 '22 08:10

Jeromy Anglim


There is a mismatch of { } in the .Rd file that causes the issue. It is very hard to detect,Make sure you have matched pairs before doing R CMD check pkg_name.

like image 27
alittleboy Avatar answered Oct 30 '22 08:10

alittleboy


This error message may get more hits now that roxygen2 (mercifully) supports markdown. If converting from an old LaTeX-style file, some LaTeX-legal syntax may still by hiding from manual conversion.

Converting from `word' to 'word' resolved my Rd parsing error (i.e., changed the leading backtick to a conventional quote).

like image 36
wibeasley Avatar answered Oct 30 '22 08:10

wibeasley