[R] inconsistency in tryCatch...

akshay kulkarni @k@h@y_e4 @end|ng |rom hotm@||@com
Wed Jun 22 21:31:58 CEST 2022

Dear Bert,
                 THanks a lot! I don't know how I escaped such a simple reasoning...

Your sincerely,
From: Bert Gunter <bgunter.4567 using gmail.com>
Sent: Thursday, June 23, 2022 12:51 AM
To: akshay kulkarni <akshay_e4 using hotmail.com>
Cc: R help Mailing list <r-help using r-project.org>
Subject: Re: [R] inconsistency in tryCatch...


On Wed, Jun 22, 2022 at 12:01 PM akshay kulkarni <akshay_e4 using hotmail.com<mailto:akshay_e4 using hotmail.com>> wrote:
Dear members,
                          I have the following code:

        > tryCatch(function() print("fred"),  error = function(e) sum(1:3), finally = sum(1:3))
         function() print("fred")

The expected output from the tryCatch call should be to print "fred" to the console,
NO! You have simple defined the function -- you have not called/executed it. This defines and calls it:

> tryCatch({function() print("fred")}(),  error = function(e) sum(1:3), finally = sum(1:3))
[1] "fred"


and exit, but as seen above, it is outputting
          function() print("fred")

Can you people please shed some light on what is happening?

thanking you,
Yours sincerely,

        [[alternative HTML version deleted]]

R-help using r-project.org<mailto:R-help using r-project.org> mailing list -- To UNSUBSCRIBE and more, see
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

	[[alternative HTML version deleted]]

More information about the R-help mailing list