[R] Scripting with an external editor

Jim Lemon bitwrit at ozemail.com.au
Sun Mar 30 14:45:13 CEST 2003

Hi again,

If my trawling through the "connections" code is correct, a pipe 
connection is designed to read to EOF before returning its input to the 
parsing function. Blocking is not an option with this type of connection. 
As I do not know how to spoof an EOF on an open pipe, it looks like I 
would have to rewrite 3 or 4 fairly low level functions to return input on 

My impression is that this is the wrong way to go about this. After all, I 
am sure that something similar is already being done using the present 
connection functions. Any suggestions as to where else I might look would 
be greatly appreciated.

OS - Linux
R v1.5.1

To reiterate, what I am attempting to do is to send selected text from an 
external editor to the R command line, where it will be processed as if 
entered from the keyboard. I have accomplished everything except getting 
the selections of text which are sent from the external editor to be 
processed individually rather than all in a bunch when the external editor 
exits. For example:

Select the following text in the editor and send it:

cat("Mean of x\n")

R shows:

Mean of x
[1] 5.5

Select more text and send it:

cat("Sum of x\n")

R shows:

Sum of x
[1] 55

What happens now - selections are sent, but nothing happens until the 
external editor is closed, at which point, R shows:

Mean of x
[1] 5.5
Sum of x
[1] 55



More information about the R-help mailing list