Unexpected section header '\examples' when checking R package
Asked Answered
D

4

17

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!

Diazotize answered 7/8, 2012 at 19:57 Comment(6)
It would be helpful if we could see the .Rd file in question....Wellfed
I've experienced this issue before - the problem was that I forgot to close a {} bracket pair earlier on in the .Rd file. Maybe try checking for that?Oxytocic
@AriB.Friedman: thanks for the reply! I found the issue in my .Rd file.Diazotize
@Edward: Yes, there is indeed a mismatch of {} found in the .Rd file. Thanks a lot!Diazotize
@Diazotize Have you considered using roxygen2 to create your help files?Undenominational
If you fixed the issue, could you answer your own question (so that others can learn from the example and the question will be removed from the unanswered questions feed?)Stickleback
D
6

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.

Diazotize answered 8/8, 2012 at 4:4 Comment(0)
C
43

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.

Chishima answered 15/10, 2013 at 0:14 Comment(0)
D
6

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.

Diazotize answered 8/8, 2012 at 4:4 Comment(0)
D
3

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

Dredi answered 18/3, 2017 at 18:53 Comment(1)
I had it because i used the backticks and forgot to addRoxygen: list(markdown = TRUE) to the description fileCoastwise
A
1

I generated this error when I incorrectly escaped some asterisks in my documentation. I had typed 1.*\.*\ instead of 1.\*.\*. That resulted in the end of the line of text falling outside of the {} brackets.

Afar answered 4/5 at 0:23 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Joejoeann

© 2022 - 2024 — McMap. All rights reserved.