On 14/04/2026 21:14, Sven Schreiber wrote:
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.

I find the idea _very_ attractive too. Beside Sven's remakes, there are other two points that are IMO worth considering:

  1. why not rows too?
  2. how about string arrays for multiple selection? 
-- 
-------------------------------------------------------
  Riccardo (Jack) Lucchetti
  Dipartimento di Scienze Economiche e Sociali (DiSES)

  Università Politecnica delle Marche
  (formerly known as Università di Ancona)

  r.lucchetti@univpm.it
  http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------