You might want to have a look at 'source.mvb' & friends in the 'mvbutils' 
package. It's designed to allow control of nested sourcing, and to allow 
interspersed data and commands in a single self-contained file. Unlike 
'source', 'source.mvb' reads each statement and immediately executes it, before 
proceeding to the next; hence it has do the parsing to figure out when a 
statement is complete.  It relies on 'pushBack' so doesn't work with 'stdin', 
at least in 1.9.x, which is a pity.

['mvbutils' needs updating to work perfectly with R2.x, but mostly still works.]

>From the doco:

DESCRIPTION

'source.mvb' works like 'source(local=TRUE)', except you can intersperse 
free-format
data into your code. 'current.source' returns the connection that's currently 
being
read by 'source.mvb', so you can redirect input accordingly. To do this 
conveniently
inside 'read.table', you can use 'from.here' to read the next lines as data 
rather than
R code.

HTH and apologies if not

Mark


*******************************

Mark Bravington
CSIRO (CMIS)
PO Box 1538
Castray Esplanade
Hobart
TAS 7001

phone (61) 3 6232 5118
fax (61) 3 6232 5012
[EMAIL PROTECTED] 

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of
> [EMAIL PROTECTED]
> Sent: Tuesday, 30 November 2004 11:28 PM
> To: Martin Maechler
> Cc: Duncan Murdoch; [EMAIL PROTECTED]
> Subject: Re: [Rd] a better "source(echo=TRUE)" {was "....how to
> pause...."}
> 
> 
> >>>>> On Tue, 30 Nov 2004 12:51:12 +0100,
> >>>>> Martin Maechler (MM) wrote:
> 
> [...]
> 
>   > But to do this might be more tricky than at first thought:
>   > Of course you can readLines() the source file and writeLines()
>   > them to whatever your console is. The slightly difficult thing
>   > is to "see" which junks to ``send to R'' , i.e. to 
> parse() and eval().
>   > The basic problem seems to see when expressions are complete.
> 
> > Maybe we should / could think about enhancing parse() {or a new
>   > function with extended behavior} such that it would not only
>   > return the parse()d expressions, but also indices (byte or even
>   > line counters) to the source text, indicating where each of the
>   > expression started and ended.
> 
>   > That way I could see a way to proceed.
> 
> Yes, that would be also *very* handy for Sweave, where I parse/deparse
> exactly for the reasons Martin describes: to get complete expressions
> and to know where output should be inserted.
> 
> .f
> 
> ______________________________________________
> [EMAIL PROTECTED] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to