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

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to