On Fri, 19 Feb 2021, Riccardo (Jack) Lucchetti wrote:

We have the very nice stack() function, that helps you turn a list of series 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:

<hansl>
set verbose off

function matrix unstack(series x, series names)

   errorif($datatype != 3, "This function needs panel data")
[...]
</hansl>

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 would be:

function matrix unstack(series x, series names[null], \
   strings S[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.

Allin
_______________________________________________
Gretl-devel mailing list -- gretl-devel@gretlml.univpm.it
To unsubscribe send an email to gretl-devel-le...@gretlml.univpm.it
Website: 
https://gretlml.univpm.it/postorius/lists/gretl-devel.gretlml.univpm.it/

Reply via email to