[R] cleaning up a vector

2010-10-01 Thread mlarkin
I calculated a large vector. Unfortunately, I have some measurement error in my data and some of the values in the vector are erroneous. I ended up wih some Infs and NaNs in the vector. I would like to filter out the Inf and NaN values and only keep the values in my vector that range from 1 to

Re: [R] cleaning up a vector

2010-10-01 Thread Henrique Dallazuanna
Try this: x[is.finite(x)] On Fri, Oct 1, 2010 at 2:51 PM, mlar...@rsmas.miami.edu wrote: I calculated a large vector. Unfortunately, I have some measurement error in my data and some of the values in the vector are erroneous. I ended up wih some Infs and NaNs in the vector. I would like

Re: [R] cleaning up a vector

2010-10-01 Thread Erik Iverson
Mike, Small, reproducible examples are always useful for the rest of the us. x - c(0, NA, NaN, 1 , 10, 20, 21, Inf) x[!is.na(x) x =1 x= 20] Is that what you're looking for? mlar...@rsmas.miami.edu wrote: I calculated a large vector. Unfortunately, I have some measurement error in my data

Re: [R] cleaning up a vector

2010-10-01 Thread Peter Langfelder
On Fri, Oct 1, 2010 at 10:51 AM, mlar...@rsmas.miami.edu wrote: I calculated a large vector.  Unfortunately, I have some measurement error in my data and some of the values in the vector are erroneous.  I ended up wih some Infs and NaNs in the vector.  I would like to filter out the Inf and

Re: [R] cleaning up a vector

2010-10-01 Thread Marc Schwartz
On Oct 1, 2010, at 12:51 PM, mlar...@rsmas.miami.edu wrote: I calculated a large vector. Unfortunately, I have some measurement error in my data and some of the values in the vector are erroneous. I ended up wih some Infs and NaNs in the vector. I would like to filter out the Inf and NaN

Re: [R] cleaning up a vector

2010-10-01 Thread Henrique Dallazuanna
Complementing: findInterval(x[is.finite(x)], 1:20) On Fri, Oct 1, 2010 at 2:55 PM, Henrique Dallazuanna www...@gmail.comwrote: Try this: x[is.finite(x)] On Fri, Oct 1, 2010 at 2:51 PM, mlar...@rsmas.miami.edu wrote: I calculated a large vector. Unfortunately, I have some measurement