The function addTaskCallback() allows you to add some custom code that will run after other code (example).
Is there a way in R of achieving the opposite, that is, to add some code that will run before other code?
What I know so far
I know I could edit the actual script, but I'd prefer to create a call back that runs before other code (sometimes known as a 'pre-hook', or 'before hook'.
You can do that if you write your own front end. It doesn't need to be a full front end like RStudio, simply something to collect inputs and evaluate them.
For example, if you want to do this on source code from a file, this is the sort of thing you could do:
This doesn't do anything very fancy but it's the basic outline.