32  R RStudio: breakpoint

32.1 Using RStudio breakbpoint

  • In the RStudio environment, you can use breakpoint to jump to a particular location as an alternative to using the browser function.

  • Set an editor breakpoint by clicking to the left of the line number in the source file (or Shift+F9 with curson on the line).

  • Source the script if required.

  • Once in the browser mode, move around the function as mentioned before.

  • One advantage is that you do not need to delete the line including browser() as before.

32.2 Set the breakpoint

32.3 Source the script

32.4 Run the function


You can also put a breakpoint within a function and investigate each step of the execution, even if the function does not run into any errors.

Code
X = c(NA, 12, -15, 14, 18)
fn_Mean(X, na.rm = TRUE)