G'day Federico,

On Wed, 17 May 2023 10:42:17 +0000
"Calboli Federico (LUKE)" <federico.calb...@luke.fi> wrote:

> I_d be obliged if someone can explain why tryCatch assigns items with _<-_ 
> and not _=_.

It is not just tryCatch but any function.  In function calls the "=" is
used to assign actual arguments to formal arguments, not for
assignments.  

That is why "plot(fm <- lm(eruptions ~ waiting, faithful)" works but
"plot(fm = lm(eruptions ~ waiting, faithful)" does not.

The only universal assignment operator, AFAIK, is "<-".  Well, and "->".
Long time ago "_" used to be one too, but that is long ago.  

The usual advice was that if you do not know when "=" does not work as
assignment operator then always use "<-" for assignments. :)

The final thing you have to take care of that in function calls you
have to be sure that the argument is actually evaluated (R has lazy
evaluation) to ensure that the assignment is actually executed.

Cheers,
        
        Berwin

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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