On Sat, 3 Feb 2018, oleg_komashko(a)ukr.net wrote:
function string get_rnames(matrix M)
string s = sprintf("%d",M)
nss = nlines(s)
string line
scalar i = 1
strings S = array(nss)
loop while getline(s, line) -q
S[i]= sprintf("%s", line)
i++
endloop
ret = ""
if nelem(strsplit(S[1])) == 2
loop i = 1..nss -q
ret = ret~" "~strsplit(S[i])[1]
endloop
ret = strstrip(ret)
endif
return ret
end function
# example
M = I(2)
M[1,1] = NA
rownames(M, "a b")
eval get_rnames(M)
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.
Allin