From simon.urbanek at r-project.org  Wed Jul 19 16:29:08 2006
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Wed, 19 Jul 2006 10:29:08 -0400
Subject: [Rd] ASCII dump from an REXP (JRI)
In-Reply-To: <5390018.post@talk.nabble.com>
References: <5390018.post@talk.nabble.com>
Message-ID: <CF587A7B-86EE-4E72-A85D-B06B486C5C6B@r-project.org>

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



[Rd] ASCII dump from an REXP (JRI)
Simon Urbanek