[R] difference between script and a function....

akshay kulkarni @k@h@y_e4 @end|ng |rom hotm@||@com
Sat Dec 24 17:20:16 CET 2022


Dear Ivan,
                   Thanks a lot.....!

Thanking you,
Yours sincerely,
AKSHAY M KULKARNI
________________________________
From: Ivan Krylov <krylov.r00t using gmail.com>
Sent: Saturday, December 24, 2022 9:27 PM
To: akshay kulkarni <akshay_e4 using hotmail.com>
Cc: R help Mailing list <r-help using r-project.org>
Subject: Re: [R] difference between script and a function....

On Sat, 24 Dec 2022 15:47:14 +0000
akshay kulkarni <akshay_e4 using hotmail.com> wrote:

> How do you debug if there is an error, particularly if I run the
> script from the BASH prompt?

Post-mortem debugging for non-interactive R scripts can be enabled by
setting options(error = quote(dump.frames("A_SUITABLE_FILE_NAME",
to.file = TRUE))) in your script. See ?dump.frames for more information.

When you're running command-line R interactively, the main tools at
your disposal are traceback() and browser() (see their respective help
pages). There are two main ways to use the browser: (1) by setting the
debugging flag on a function via debug(function) or debugonce(function)
-- you will land in the browser when the function is called -- and (2)
by setting options(error = recover), which will launch the browser at
the time of the crash, letting you walk the stack and inspect the
values of various variables.

For more information on pure-R debugging, see The R Inferno book:
<https://www.burns-stat.com/documents/books/the-r-inferno/>

--
Best regards,
Ivan

	[[alternative HTML version deleted]]



More information about the R-help mailing list