browse: Debugging utilities

View source: R/utilities.R

browseR Documentation

Debugging utilities

Description

Debug specified function func by entering a browser() right at the beginning (browse()) or end (browse_end()) of the function.

Usage

browse(func, ...)

browse_end(func, ...)

Arguments

func

An R function to be browsed.

...

Arguments to the function func that is to be browsed.

Details

These are convenience shorthands for R's builtin debug tools, like debugonce() and the trace()/untrace() combination.

Value

Returns the result of func(...). Enters a browser().

Functions

  • browse_end(): Enter browser() at the end of the function call to func(...). This only works, if the function can execute without error until its end. Otherwise, the error will be thrown.

See Also

browser(), debugonce(), trace()

trace()

Examples


# Define a simple function for this example
my_func = function(a) { for (i in 1:5) { a = a + i }; return(a) }

# Enter a browser at the beginning of the function
browse(my_func, 0)

# Enter a browser at the end of the function. This allows us to inspect 
# the function's local variables without having to go through the whole loop.
browse_end(my_func, 0)


growR documentation built on May 29, 2024, 9:12 a.m.