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?

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)?

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.

Reply via email to