Am 13.04.2026 um 22:50 schrieb Cottrell, Allin:
It strikes me that in some cases it might be convenient to be able
to
extract a column from a gretl matrix that has column-names attached by
name rather than column-number. The primary case I have in mind is a
matrix returned by a function (or in a bundle returned by a function),
where the columns basically represent series. So, given
matrix M = some_func(some_args)
series some_name = M[,4]
one could do, say,
matrix M = some_func(some_args)
series some_name = M[,"forecast"]
Any thoughts on this? If the idea seems attractive I can see about
implementing it.
Yes it does seem attractive. A follow-up question would be: what's the
error if the name doesn't exist? Index out of bounds?
Another thought: Instead of having named columns collected in a matrix,
the same columns could already be stored inside a bundle with the same
names, and then would be accessible by name without the square brackets
and the quotes, like B.forecast. On the other hand, if the columns are
in the same matrix, that would ensure that their lengths are equal,
which might be an advantage.
thanks
sven