[R] Output from examples in help files

ripley@stats.ox.ac.uk ripley at stats.ox.ac.uk
Fri Mar 29 20:03:27 CET 2002


On Fri, 29 Mar 2002, John Fox wrote:

> Dear Brian,
>
> At 07:02 AM 3/29/2002 +0000, Prof Brian D Ripley wrote:
> >On Thu, 28 Mar 2002, John Fox wrote:
> >
> > > At 07:14 PM 3/28/2002 -0500, Frank E Harrell Jr wrote:
> > > >I have a large number of troff help files which are automatically
> > > >converted to .Rd files.  Many of these have examples which contain the
> > > >printed output of the examples.  This makes example(functionname) not
> > > >work.  Is there a way to avoid removing all this output by delimiting it
> > > >in some way such that the output will not appear in R-ex?  Secondly, it
> > > >would be nice if there was a place where output would be placed so that
> > > >users could check results on different platforms or after upgrading a
> > package.
> > >
> > > I've noticed that in many cases output in help-file examples is simply
> > > commented out, and I've followed this practice myself; for example:
> >
> >It is better to use \dontrun{} to do this. (That did not exist when a lot
> >of the examples you are seeing were prepared.)
>
> Unless I've missed something, the problem with using \dontrun{} for all of
> the examples (assuming that all show output) is that none of the examples
> would be run. As well, with the output not differentiated visually from the
> input, it might be hard for the reader to distinguish the two.

Just put \dontrun{} around the output.  I don't find it hard to
distinguish the commands and output, and nor would I expect this to be a
problem once people know what R commands look like.

> > > Of course, you'll probably have to add the #'s manually. (I agree that it
> > > would be nice if output were handled explicitly in .Rd files.)
> >
> >To do that needs much more markup, including have separate \example{}
> >sections inside \examples{}.
>
> I personally wouldn't find it onerous to put output within something like
> \example{} or \output{} -- it would be less work than adding #'s.

or \dontrun{}!

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list