Tip: put each argument on a separate line and debug in interactive mode
- Whilst it would be the ‘best practice’ to use
debug()
or browser()
to examine the state of the function at runtime, it can be very helpful to run in interactive mode for debugging complex issues or building up pipelines
- In the example shown I have created some dummy data and set the required values up in the first two lines, which remain commented out so they don’t interrupt the function when we load it
- I then load the required arguments values (notice how I made each one a seperate line to make it easy to run them)
- I can then step through each line in the global environment
- Once I am happy with the function I can then load it (using
source
) and then run the test which is at the bottom
- Creating this result