I found it difficult to debug after enclosing code blocks into functions although this makes the workflow structure more clear. Is there a way to still load these objects inside the R functions into the environment?
Asked
Active
Viewed 85 times
1 Answers
1
You might be looking for <<-
, which will look for a variable with that name in the enclosing environments and update it there. If it doesn't find a variable with that name it will create it in the global environment. See How do you use "<<-" (scoping assignment) in R? for some discussion. I'm not familiar with assign()
, but the second answer of that question suggests it might be more appropriate for what you want to do.
Beware, these can make functions behave strangely if you lose track of what is being assigned in what environment. Alternate methods for debugging would be to use debug()
, debugonce()
, or put a browser()
call in the function.

DavidLukeThiessen
- 590
- 2
- 17