Subject: Retaining comments when using `example'
From: Douglas Bates (email@example.com)
Date: Wed 28 Jul 1999 - 08:41:48 EST
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
col> ma <- matrix(1:12, 3, 4)
col> ma[row(ma) == col(ma) + 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: firstname.lastname@example.org
This archive was generated by hypermail 2b25 : Tue 04 Jan 2000 - 14:16:06 EST