On Sat, 3 Feb 2018, Sven Schreiber wrote:
> Am 03.02.2018 um 03:33 schrieb Allin Cottrell:
>> On Sat, 3 Feb 2018, oleg_komashko@ukr.net wrote:
>
>>> Is there a less roundabout way to extract row names
>>> of a matrix
>>
>> OK, alright! By popular demand, there's now a rowname() function in git.
>
> Thanks!
>
> I've just reviewed the situation with colnames/colname/rownames, however, and
> I must say I find it not really obvious that colname --and now also rowname--
> *gets* the names, while colnames/rownames *puts* names. The labeling seems
> confusing to me.
>
> Could we perhaps rename the new rowname to something like rnameget (or
> similar), and perhaps introduce a similar alias like cnameget for colname?
>
> And a further possible extension: Similar to strsplit(), the functions
> colname and rowname (or their new aliases) might also return an array of
> strings of *all* names in the case that the second index argument is omitted.
Might as well strike while the iron is hot: that's now in git.
Example:
<hansl>
open data9-7
smpl 1 8
list L = QNC INCOME
matrix M = {L}
strings rnames = array(8)
loop i=1..8 -q
rnames[i] = obslabel(i)
endloop
rownames(M, rnames)
print M
eval cnameget(M, 2)
eval cnameget(M)
eval rnameget(M, 8)
eval rnameget(M)
# exercise alias
eval colname(M, 1)
</hansl>
Allin
_______________________________________________
Gretl-devel mailing list
Gretl-devel@lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-devel