On 07-09-2012, at 21:54, William Dunlap wrote:

> The functions
>   f1 <- function(x) x <- x + 1
> and
>   f2 <- function(x) x + 1
> both return the same value.  You can see
> this by doing
>   z1 <- f1(10) ; print(z1)
>   z2 <- f2(10) ; print(z2)
> or just
>   print(f1(10))
>   print(f2(10))
> 
> f1(x) does not automatically print its output when run
> directly from the command line while f2(x) does because
> assignment statements inhibit autoprinting.

Ouch. 
And it explains why my version with (x<-x+1) did print the result.

Thanks.

Berend

______________________________________________
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