Skip to content

how to replace NaN in a vector

3 messages · Yong Wang, Duncan Murdoch, David Scott

#
Hi, all

a vector such as

(1,2,4,-1,NaN,2,4,NaN)

if try to replace all the NaN with a numerical value, what's the easiest 
way?
thanks a lot



best
yong
#
On Mon, 8 Mar 2004 18:18:28 -0600 (CST), you wrote:

            
x[is.nan(x)] <- 42

See ?NaN for related functions.

Duncan Murdoch
#
On Mon, 8 Mar 2004, Yong Wang wrote:

            
Is this what you wanted?
[1]    1    2    4   -1 -999    2    4 -999



David Scott


_________________________________________________________________
David Scott	Department of Statistics, Tamaki Campus
		The University of Auckland, PB 92019
		Auckland	NEW ZEALAND
Phone: +64 9 373 7599 ext 86830		Fax: +64 9 373 7000
Email:	d.scott at auckland.ac.nz 


Graduate Officer, Department of Statistics