On Mon, 6 Oct 2014, Giuseppe Vittucci wrote:
Ok, I see Jack's points.
That's a request for a suggestion for a different issue.
I have a matrix with some nan values (produced by the splendid function
"aggregate" ;-)) and I want to substitute the nan with zeros.
I have tried the replace command but it does not work with nan inside
matrices (while it works when the nan are in series).
The following command (which uses the fact that a nan is different from
itself) works as expected:
matrix m2 = (m1 - m1 .= 0)? m1 : 0
But I was asking if there is a more direct way to substitute nans inside
a matrix.
That's clever. You could improve on that via
matrix m2 = (m1 .= m1) ? m1 : 0
although probably the following is more natural
matrix m2 = ok(m1) ? m1 : 0
but I guess we could extend the misszero() function to matrices.
Allin, can you think of a good reason why we shouldn't?
-------------------------------------------------------
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
-------------------------------------------------------