Retaining comments when using `example'

About this list Date view Thread view Subject view Author view Other groups

Subject: Retaining comments when using `example'
From: Douglas Bates (bates@stat.wisc.edu)
Date: Wed 28 Jul 1999 - 08:41:48 EST


Message-ID: <6rk8rl7m1f.fsf@verdi.stat.wisc.edu>

I find the `example' function, used to run the examples from a help
page, to be very useful. It would be even more useful if I could find
a way to have the comments echoed along with the example code.

For example, the example section of col.Rd from the base library reads

 # extract an off-diagonal of a matrix
 ma <- matrix(1:12, 3,4)
 ma[row(ma)==col(ma) + 1]

 # create an identity 5-by-5 matrix
 x <- matrix(0,nr=5,nc=5)
 x[row(x)==col(x)] <- 1

but example(col) produces

R> example(col)

col> ma <- matrix(1:12, 3, 4)

col> ma[row(ma) == col(ma) + 1]
 [1] 2 6

col> x <- matrix(0, nr = 5, nc = 5)

col> x[row(x) == col(x)] <- 1

Is there a way to retain the comments? I notice that `example' ends up
calling the `source' function to do the actual running of the code.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b25 : Tue 04 Jan 2000 - 14:16:06 EST