Re: [Rd] Roxygen: @example tag does not work for me

From: Janko Thyson <>
Date: Thu, 04 Nov 2010 19:12:39 +0100

> -----Ursprüngliche Nachricht-----
> Von: [] Im Auftrag von
> Hadley Wickham
> Gesendet: Donnerstag, 4. November 2010 19:00
> An: Janko Thyson
> Cc: r-devel_at_r-project. org
> Betreff: Re: [Rd] Roxygen: @example tag does not work for me
> > I thought that @example would take the R code in "tests/foo.R" (this
> file
> > also exists) and append it to the .Rd-file. However, there is no
> > \examples{...} section in my roxygen-processed .Rd-file after running
> > roxygenize(). It just seems as if @example is just neglected. Should
> I put
> > the file in another directory?
> I would suspect that the path would be relative to either man/ or R/ -
> so you probably want ../tests/...

Thanks, I'll try that.

> But including your unit tests as examples seems like a pretty odd
> thing to do - they do serve rather different purposes.

Sure. Don't know if "unit test" is a bit of an overkill name for my stuff. But I usually do poor man's testing of my functions in a script where I call the function with different settings. And I thought about tagging some parts of those scripts that qualify as good examples, have a routine that picks up those tagged sections and writes it to, say, "/inst/examples/foo.R". I could also create scripts that only feature good example code and use "@example .../inst/examples/foo.R" on it. No luck with that @example in general yet, though.

I also tried appending the example code directly to the respective post-roxygenized .Rd-file in the man directory (write "\examples{ <example_code>}"), but that doesn't get me anywhere either. Hitting "?foo" after the package has been build and installed does show the examples then, but the formatting is totally wrong (i.e. no "Examples" section header but just dumped right after the Note section etc.). I'm kinda out of clues now.

Thanks for your comments though.


> Hadley
> --
> Assistant Professor / Dobelman Family Junior Chair
> Department of Statistics / Rice University
> mailing list Received on Thu 04 Nov 2010 - 18:15:06 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 05 Nov 2010 - 12:10:16 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive