[R] Vector of Numbers Not Output to Screen

Duncan Murdoch murdoch.duncan at gmail.com
Sun Jul 20 15:30:58 CEST 2014


On 17/07/2014, 10:00 PM, Dario Strbenac wrote:
> The example in the question was not inside a user function.

The explanations you were given were slightly inaccurate.  The usual
rule is that results returned at the top level are printed unless they
are marked as invisible.  (There are a few cases where "top level" is
faked, e.g. in example code, and in Sweave.)

When you do something like

if(test) { a; b; c }

you have an expression that returns NULL invisibly if the test is FALSE,
and returns the value of the block (i.e. c) visibly if it is TRUE.  It
is the value of the if that is printed.

There is no difference in the handling of a, b and c:  each is an
expression that returns the value of the corresponding variable without
marking it as invisible.  But none of them are top-level expressions, so
none of them print.

Duncan Murdoch



More information about the R-help mailing list