Skip to content

Writing R demo files

1 message · Olivia Lau

#
Hi,

Is it possible to comment demo() files?  I am trying to write
demos that have comments, R commands, and R output so that new
users will be able to follow along.

I have tried readline(), but that returns the readline("...")
command statement as well as the output from readline, and the
demos are ugly.  I have also tried:

options(echo = FALSE)
print("my comments here")
options(echo = TRUE)

[some R commands here]

options(echo = FALSE)
print("more comments")
options(echo = TRUE)

but options() seems to work only at the beginning of the file.
Is there a special command or procedure that I should use?

Thanks,

Olivia Lau