R’s help system is great, and I love that almost all help pages for a function include an example, but sometimes I wish there was a way to see the results of the example code without copying and pasting into my current session. This goes doubly for graphic functions.
Is there a way to do one of the following;
- Compile my help files with the results of the example code inline
- Generate pdf’s of the help file with the results
- Have a web site with the help files and the results of the examples.
example(foo)is the usual interface to functionfoo. It will echo the example code to the console a line/chunk at a time, and pause between plots.R’s help system will soon be more fully dynamic, but this will only (IIRC) help matters if the package author rewrites all or parts of the man pages to include dynamic content. I’m not aware of a proposal to include output from examples in the new dynamic help, but it could potentially be done. If you have the standard R toolchain installed, you could grab package sources and check them – that creates an R file with the concatenated example code used for checking that the examples work.
(2) is getting a bit close to a vignette.