I think using "type = lag/lead" is a lot of unnecessary typing, and using a negative shift would be much simpler and more intuitive. It would also allow for more nifty multiple shifts going from lead to lag by typing e.g. shift(vec, -5:5).
The "type" argument can still stay and negative shift would simply reverse the meaning of "type".
n = 0 should also be accepted and simply return the original vector.
I think using "type = lag/lead" is a lot of unnecessary typing, and using a negative shift would be much simpler and more intuitive. It would also allow for more nifty multiple shifts going from lead to lag by typing e.g.
shift(vec, -5:5).The "type" argument can still stay and negative shift would simply reverse the meaning of "type".
n = 0should also be accepted and simply return the original vector.