I just got Copilot to write a function for me. Have you ever run MASS::stepAIC on a linear model that includes poly(x,3) terms and factor(x) terms? These are included as a block. What about if you want to select all the single degree of freedom terms to maximise AIC? stepAIC will not do it, so you need to refit the model in base form, which is a pain.
It took five sequential attempts to get Copilot to give me a function that worked properly for the range of cases I wanted (attached) One roadblock was that you can apply functions to the y-variable in a formula and I wanted this to pass thorough the refitting. Anyway, below is the function it produced.
I think this would have taken me a long time to write, especially as it is not in my comfort zone. Translating formulas into text and selecting components of the model with the same name is not something that inspires me.
So I would call it a win, but the first four versions of this function did not work properly at all.