You want to debug a script or function.
Insert this into your code at the place where you want to start debugging:
When the R interpreter reaches that line, it will pause your code and you will be able to look at and change variables.
In the browser, typing these letters will do things:
|n (or Return)||Next step|
|Ctrl-C||go to top level|
When in the browser, you can see what variables are in the current scope.
To pause and start a browser for every line in your function:
By default, every time you press Enter at the browser prompt, it runs the next step. This is equivalent to pressing
n and then Enter. This can be annoying. To disable it use:
To start debugging whenever an error is thrown, run this before your function which throws an error:
If you want these options to be set every time you start R, you can put them in your