[R] Vector of Numbers Not Output to Screen

Rolf Turner r.turner at auckland.ac.nz
Fri Jul 18 03:48:03 CEST 2014


On 18/07/14 11:32, David Winsemius wrote:
>
> On Jul 17, 2014, at 9:27 AM, Rui Barradas wrote:
>
>> Hello,
>>
>> Also, unlike what the op says, if statements are functions, explaining the behavior he got.
>
> I'm not sure that is correct. The help page says if() is a control-construct. I think the function is actually "{"
>
>> {rnorm(10); rpois(10, 3)}
>   [1] 5 3 5 5 7 3 4 4 0 5
>
> See
>
> ?Paren

It has nothing to do either with if() or Paren.  It is the ***user's*** 
function that is suppressing the output.  Consider:

foo <- function(){
x <- 17
x
y <- 42
y
}

If you type foo() you get

[1] 42

which is the *value returned by the function.  The value of the "x" 
statement inside foo() is made invisible (and would have to be enclosed 
by print() to be made visible).

cheers,

Rolf


-- 
Rolf Turner
Technical Editor ANZJS



More information about the R-help mailing list