R debugging / introspection for functions

New R/Rstudio user here. I love the introspection capabilities for objects in the local/global scope provided by the environment panes, but is there anyway to get this to work inside function in my main code?

I see you can swap focus to various packages, is there anyway to do the same for functions? I was hoping you could either click-expand function objects look inside or its would automatically shift focus when using browser() but no luck.

Worst case, I assume there is some hacky solution to just copy all function objects to global (for debug only)?

Not sure what you are looking for, so difficult to give you any pointers, but can you expand on what do you want to see inside of the function that browser() doesn't give?

Oh wow, I feel dumb. Browser() gives exactly what I want, could have sworn it didn't work when I first tried it.

That answers my main question.

Is there anyway to do the same (point the navigation pane at a functions scope) other than hitting browser() inside of it? e.g. like you can for packages, regardless of current scope

I think, browser() is probably easiest, but you can also you use debug, debugOnce etc.

For more about this you'll probably find following resources useful - https://support.rstudio.com/hc/en-us/articles/205612627-Debugging-with-RStudio#using-the-debugger, https://resources.rstudio.com/rstudio-conf-2018/debugging-techniques-in-rstudio-amanda-gadrow

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.