On 16/02/2024 17:38, Artur T. wrote:
Hi Gretl community,
I am wondering whether there is a way to ignore printing NA values in a
matrix when calling the printf command
Suppose you have a matrix like this:
Model=1 Model=2 Model=3 Model=4
INT nan -0.12 -0.17 -0.06
pv nan 0.00 0.00 0.09
U -0.07 -0.09 -0.11 nan
pv 0.00 0.00 0.00 nan
intercept -176.03 -108.49 6.37 -203.84
pv 0.00 0.00 0.00 0.00
l_INC 6.79 4.28 nan 7.81
pv 0.00 0.00 nan 0.00
trend -0.01 -0.01 -0.01 -0.01
pv 0.00 0.00 0.00 0.00
but you would like to replace all nan values by "" (empty string or no
value) for better readability. This should not be the default, but maybe
there exists some format argument of which I am not aware of.
How about this?
<hansl>
set seed 1234
C = muniform(5,3)
C[2,3] = NA
C[3,1] = NA
tmp = sprintf("%6.2f", C)
new = strsub(tmp, "nan", " ")
printf "%s", new
</hansl>
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------