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

Janko Thyson janko.thyson at ku-eichstaett.de
Thu Nov 4 19:12:39 CET 2010

> -----Ursprüngliche Nachricht-----
> Von: h.wickham at gmail.com [mailto:h.wickham at gmail.com] 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,

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
> http://had.co.nz/

More information about the R-devel mailing list