#<hansl
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)
#hansl>