[Rd] ASCII dump from an REXP (JRI)

Simon Urbanek simon.urbanek at r-project.org
Wed Jul 19 16:29:08 CEST 2006


Adam,

please use stats-rosuda-devel or private mail, your mail ended up on  
R-devel again ...

On Jul 18, 2006, at 10:56 PM, way4thesub wrote:

> evaluate an R expression. Is there a way to just print, verbatim,  
> what R evaluates to the screen (ie just a pure ASCII dump with no  
> regard to the data type)?
>

Probably the easiest is (replace "a" with any expression you want to  
show):

System.out.println(reng.eval("paste(capture.output(print 
(a)),collapse='\n')").asString());

Another alternative is to use callbacks - i.e. create a class that  
implements RMainLoopCallbacks and simple reng.eval("print(a)"); will  
cause rWriteConsole to be called with the output. This approach is  
more suitable for console-like GUIs.

Cheers,
Simon



More information about the R-devel mailing list