[R] Display/show the evaluation result of R commands automatically

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Sun Jul 31 14:16:08 CEST 2011


> h <- taskCallbackManager()
> h$add(function(expr, value, ok, visible) {if(!visible){print(value)};TRUE})


On Sun, Jul 31, 2011 at 12:15 PM, Anthony Ching Ho Ng
<anthony.ch.ng at gmail.com> wrote:
> Hello R-help,
>
> I wonder if it is possible to configure R, so that it will
> display/show the evaluation result of the R commands automatically
> (similar to the behavior of Matlab)
>
> i.e. If I type x <- 8
>
> it will print 8 in the command prompt, instead of having type x
> explicitly to show the result and perhaps put an ";" at the end to
> suppress the output.
>
> i.e. x <- 8;
>

The first thing I think you can do by adding a task callback manager
to print the value if the value would otherwise be invisible:

 > h <- taskCallbackManager()
 > h$add(function(expr, value, ok, visible) {if(!visible){print(value)};TRUE})

 The semicolon thing would probably need rewriting bits of R at the C
code level.

 I don't think many people would use it though. And my code above
might break things. I don't use it.

Barry



More information about the R-help mailing list