If you want to break up a big function into smaller functions and you have lots of variables flying around, one simple thing you could do would be to end each intermediate part with
return(as.list(environment()))
and pass that list of values into the next function.
Here's the problem: the original function also needs "..." .
It doesn't seem to pass into as.list(environment()), and I don't know how you would pass it into the next function.
Any ideas?