This wraps the base setHook() function to provide a return value that makes it easy to undo.
setHook()
set_hooks(hooks, action = "append")
a named list of hooks - each hook can either be a function or a list of functions.
"replace", "append" or "prepend"
"replace"
"append"
"prepend"
# NOT RUN { new <- list(before.plot.new = function() print("Plotted!")) hooks <- set_hooks(new) plot(1) set_hooks(hooks, "replace") plot(1) # }
Run the code above in your browser using DataCamp Workspace