Am 06.05.2021 08:38 schrieb Sven Schreiber:
Am 06.05.2021 um 07:42 schrieb atecon:
> Hi all,
>
> I just would like to ask whether this behavior is actually expected:
>
> <hansl>
> matrix m = {1, NA; 2, 3}
> print m
> eval cum(m)
>
> ? print m
> m (2 x 2)
>
> 1 nan
> 2 3
>
> ? eval cum(m)
> 1 nan
> 3 nan
> </hansl>
>
> I expected the entry (2,2) to be 3 as this is the first valid value of
> the 2nd column.
I'd say it's expected because nans propagate. Basically you don't know
what 3 + nan is. To get what you want, I was going to say "do
cum(misszero(m))", but that doesn't work on a matrix. Maybe it should?
(But remember the old fact that a NaN and a missing value is not always
the same thing.)
True, 3 + nan remains unclear or is actually not defined. Fine for me if
that's how it is handled -- just wanted to know what's expected in this
case.
Replacing nan values in matrix can be easily done by:
<hansl>
m = ok(m) ? m : VALUE # VALUE is some numeric value
</hansl>
Thanks,
Artur