On Fri, 19 Feb 2021, Riccardo (Jack) Lucchetti wrote:
We have the very nice stack() function, that helps you turn a list of
into a single panel series. Unless I'm missing something, I don't think we
have the opposite function, that is a function turning a panel series into a
multi-column object. So, I ended up writing this:
set verbose off
function matrix unstack(series x, series names)
errorif($datatype != 3, "This function needs panel data")
My question is: is there a simpler way to accomplish the above? And if there
isn't, would it be worthwhile to add this function to the extra package?
I can't think of an easier way of doing this, and your function
seems to me a good candidate for "extra". One possible modification
function matrix unstack(series x, series names[null], \
where the caller needs to supply one of @names or @S, allowing for
the possibility that there's no handy series holding group names and
you therefore want to submit an array of group names directly. Or,
drop the @S argument but be ready to construct automatic names (e.g.
"unit%d") in case @names is not given.