Am 16.02.24 um 18:39 schrieb Riccardo (Jack) Lucchetti:
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>

Ohh, this is clever, Jack!

Thank you

Artur
_______________________________________________
Gretl-devel mailing list -- gretl-devel@gretlml.univpm.it
To unsubscribe send an email to gretl-devel-le...@gretlml.univpm.it
Website: 
https://gretlml.univpm.it/postorius/lists/gretl-devel.gretlml.univpm.it/

Reply via email to