[R] Code in Rd help files other than in \examples{}

Henrik Bengtsson hb at maths.lth.se
Tue Feb 12 17:06:46 CET 2002


I struggled with the same problems a while ago when I wanted to do a tree
structure of classes using verbatim text, but I found out that

  1) newlines with \code{} are *not* possible
  2) initial spaces in \code{} are neglected.

However, there are nasty work-arounds. For example, see

 http://www.maths.lth.se/bioinformatics/software/R/library/com.braju.sma/html/MAData.html

to get an idea what I want to do. This I do with the followind Rd code:

 com.braju.sma \cr
 \bold{Class MAData}\cr

 \code{\link[R.oo]{Object}}\cr
 \code{~~|}\cr
 \code{~~+--}\emph{\code{\link[com.braju.sma]{MicroarrayData}}}\cr
 \code{~~~~~~~|}\cr
 \code{~~~~~~~+--}\code{MAData}\cr

 \bold{Directly Known Subclasses:}\cr
 \code{\link[com.braju.sma]{TMAData}}\cr

 public static class \bold{MAData}\cr
 extends \code{\link[com.braju.sma]{MicroarrayData}}\cr

As you see, I had to replace spaces with tildes and make each line as a
seperate \code{} followed by a \cr. Also, I have no idea what it looks
like in the LaTeX generated documents. The text based help pages looks ok
though. Luckily, I generate these lines of code automatically (home made
[R] script).

So, I am afraid there is no easy solution to your problem. If you hear
about a better way, please tell me.

Cheers

Henrik Bengtsson

Dept. of Mathematical Statistics @ Centre for Mathematical Sciences 
Lund Institute of Technology/Lund University, Sweden (+2h UTC)
Office: P316, +46 46 222 9611 (phone), +46 46 222 4623 (fax)
h b @ m a t h s . l t h . s e
http://www.maths.lth.se/matstat/staff/hb/



On Tue, 12 Feb 2002, Frank E Harrell Jr wrote:

> Thank you very much for the note Friedrich.  May I ask two follow-up questions to make sure I understand all the possibilities in Rd files?  (1) Is there a pure verbatim environment for Rd files?  (2) Is there a way to put newlines inside \code{} text?  Thanks -Frank
> 
> On Tue, 12 Feb 2002 13:33:21 +0100
> Friedrich.Leisch at ci.tuwien.ac.at wrote:
> 
> > >>>>> On Mon, 11 Feb 2002 15:39:23 -0500,
> > >>>>> Frank E Harrell (FEH) wrote:
> > 
> >   > I am stumped in determining the proper syntax for including displayed S code within an R .Rd documentation file, in places other than \examples{}. I have tried
> >   > \code{
> >   >    line 1
> >   >    line 2
> >   > }
> > 
> >   > but the lines get run together.  When I terminate the lines by \cr, the "\cr" actually appears in the resulting html file.   This is all inside a customized \section{}.
> > 
> >   > On a related note, what is there a way to include large blocks of text within \examples{} that is not part of S comments?  I want such text to appear in the html help file, optimally with auto-wrapping of lines.  \dontrun{} does not appear to be exactly what I need.  I actually need multiple sub-\examples{} with intervening text but no new headings.
> > 
> >   > I am using R 1.4.0 on RedHat Linux 7.1.  Thanks in advance for pointers.
> > 
> > Sorry, we currently only support one code section per .Rd file, namely
> > the examples section. .Rd was designed to write man pages in a rather
> > strict format (such that all pages look "similar" and hence are easy
> > to use).
> > 
> > We are currently investigating new ways for writing documentation,
> > which will eventually result in new formats for writing function
> > documentation. 
> > 
> > E.g., the current development version of R has Sweave() and friends
> > which allows integrating S code in latex documents using the noweb
> > syntax. http://www.ci.tuwien.ac.at/~leisch/Sweave has some details.
> > This is meant for writing manuals, reports, etc.
> > 
> > A much more interactive approach is to use XML via Xalan, see Duncan
> > Temple Lang's SXalan package and related info on
> > http://www.omegahat.org/SXalan 
> > This route is more likely to lead to new ways for object documentation
> > (because computation on the documents is easier).
> > 
> > Of course this doesn't help you with your current problem, it is just
> > meant as an excuse why we currently do not want to add new features to
> > .Rd (and have not done so for quite some time).
> > 
> > best,
> > 
> > -- 
> > -------------------------------------------------------------------
> >                         Friedrich  Leisch 
> > Institut für Statistik                     Tel: (+43 1) 58801 10715
> > Technische Universität Wien                Fax: (+43 1) 58801 10798
> > Wiedner Hauptstraße 8-10/1071      Friedrich.Leisch at ci.tuwien.ac.at
> > A-1040 Wien, Austria             http://www.ci.tuwien.ac.at/~leisch
> > -------------------------------------------------------------------
> > 
> 
> 
> -- 
> Frank E Harrell Jr              Prof. of Biostatistics & Statistics
> Div. of Biostatistics & Epidem. Dept. of Health Evaluation Sciences
> U. Virginia School of Medicine  http://hesweb1.med.virginia.edu/biostat
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 

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