[R] how to replace NaN in a vector

Duncan Murdoch dmurdoch at pair.com
Tue Mar 9 04:57:43 CET 2004


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

>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?

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

See ?NaN for related functions.

Duncan Murdoch




More information about the R-help mailing list