[R] how to replace NaN in a vector

2004-03-08 Thread Yong Wang
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 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do

Re: [R] how to replace NaN in a vector

2004-03-08 Thread Duncan Murdoch
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 __

Re: [R] how to replace NaN in a vector

2004-03-08 Thread David Scott
On Mon, 8 Mar 2004, Yong Wang 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? thanks a lot Is this what you wanted? x-c(1,2,4,-1,NaN,2,4,NaN) y-ifelse(is.nan(x),-999,x) y [1]124