user629019 user629019 - 3 months ago 5
R Question

R: How do I set a breakpoint in a different file?

I have two files:

Main.R

Called.R

Main.R has the line

source('Called.R')

Main.R calls a function in Called.R. I can step into the function in called.R, from Main.R no problem.

However, if I set a breakpoint in the function in Called.R and call that function from Main.R, execution does not stop at the breakpoint. However, if I move the function into Main.R, execution does stop.

Any idea if RStudio's debugger can recognize breakpoints set in 'sourced' files? I can't even find the problem referred to in the documentation.

Thank

Answer

add a temporary browser() line inside of that function

Comments