I have a strong suspicion that going with stack/unstack is ultimately going to be easier than reshape. The latter is (a) very particular about its input form and arguments, and (b) you'll probably end up having to do some binds and internal manipulation anyway once you start invoking the additional pivot_* arguments.
The main complication for extending this proof of concept is handling the NSE. But I believe(?) you've already developed an internal system for deparsing NSE vectors etc. So, that could make things a lot easier.
I'm sure you've already considered this, but a simple proof-of-concept using
stack()
:Created on 2021-11-14 by the reprex package (v2.0.1)
Two asides:
stack
/unstack
is ultimately going to be easier thanreshape
. The latter is (a) very particular about its input form and arguments, and (b) you'll probably end up having to do some binds and internal manipulation anyway once you start invoking the additional pivot_* arguments.EDIT: Added
names_prefix
arg and example.