[R] source(echo=TRUE) bug (was: source() behavior I don't understand)

Richard M. Heiberger rmh at temple.edu
Mon Mar 10 04:26:10 CET 2008


Duncan,

I would like an option for all comments and blanks to be echoed.  The
reason is that I am designing a mechanism for connecting ESS to Rgui
using source().  It works for me now, but is not smooth enough to post
until I do a little bit more work on it.  Therefore I want an option
for the R Console to display all the lines in my source() code.  When
the seven lines below are sourced, only lines 1,2,4,5,6 are echoed.
Lines 3 and 7 are not echoed.  This means that well-commented user
source code will not have complete comments in the output transcript
in the Console.

## comment 1
123

## comment 4

456
## comment 7


What I would also like, but I believe would be much harder for you
to provide, is a way to get individual lines sent from ESS into the
same place that lines that are manually typed go.  The reason is that
multi-line commands, such as 

2+
  3

cannot currently be sent one line at a time (using ESS C-c C-n) to
Rgui.  They can be sent to any other R or S-Plus process one line at a
time.  I would like the same capability for the Rgui Console.  The
plan that I am developing now can send multiple lines over, either by
highlighting them and using C-c C-r, or by surrounding them with blank
lines and using C-c C-c.


Rich

-----Original Message-----
From: Duncan Murdoch [mailto:murdoch at stats.uwo.ca] 
Sent: Sunday, March 09, 2008 10:52 PM
To: Richard M. Heiberger
Cc: r-help at r-project.org
Subject: Re: [R] source(echo=TRUE) bug (was: source() behavior I don't
understand)

On 09/03/2008 10:40 PM, Richard M. Heiberger wrote:
> Thanks Duncan,
> 
> While there, can you give a new optional argument that
> will permit the echo of blanks and comments?

Comments are already echoed, leading blank lines are not (but blanks in 
comments are).  For example:

 > temp.ttt <- "ttt <- 1\n\n# comment\n\nttt"
 > cat(file="c:/temp/temp.R", temp.ttt)
 > source("c:/temp/temp.R", echo=TRUE)

 > ttt <- 1

 > # comment
 >
 > ttt
[1] 1

(I ran this in the patched version, but I believe the behaviour would be 
the same in the release as well.)

I forget exactly why I chose to suppress leading blanks, but the 
workaround of commenting the first of them is so easy, I don't think 
it's worth the trouble to add an extra option.

Duncan



More information about the R-help mailing list