On 12/04/2010 7:14 PM, Kuhn, Alexandre (NIH/NIA/IRP) [V] wrote:
Hi,

source(file,echo=T) will not echo the last comment in "file" if it is the last 
line in the file.
For instance, when sourcing a file containing the following lines

#comment 1
a<-1
#comment 2

R will echo

> #comment 1
> a<-1

What is the solution to have R echo all of the comment lines?
I think the only current solution is to have all the comment lines ahead of code lines. R doesn't specifically echo the comments, it only echoes the code, but comments that happen to precede the end of the code line are echoed as part of that line.
Specific context:
This problem arises e.g. in the context of help files (.Rd) whose example 
section contains only code that is not to be run (\dontrun markup). Running the 
function example() (that itself calls source(,echo=TRUE)) on such a file will 
not display anything (because the code is commented out in the corersponding 
files in R-ex). Is that the desired behavior of example() or is there a 
workaround (i.e. to be able write help files with only dontrun code but that 
will nevertheless echo the examples)?

I'm not sure we really want to show all the \dontrun examples, but I'll look into this, because as documented, they should be shown. (My preference would be to completely hide the \dontrun lines in example(), but that's not what is documented to happen, and that's not what happens when they are followed by code.)

Duncan Murdoch

Thank you,
Alexandre Kuhn



> sessionInfo()
R version 2.10.1 (2009-12-14) i386-apple-darwin9.8.0
locale:
[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods base ______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to