Re: [R] Dividing by 0

2008-07-26 Thread John Maindonald
. On 26 Jul 2008, at 8:00 PM, [EMAIL PROTECTED] wrote: From: nmarti [EMAIL PROTECTED] Date: 26 July 2008 1:42:09 AM To: r-help@r-project.org Subject: Re: [R] Dividing by 0 I'm well aware these are not errors, I guess I miss-wrote. I understand your concern. Thanks for passionately looking out

Re: [R] Dividing by 0

2008-07-25 Thread Jim Lemon
On Thu, 2008-07-24 at 06:57 -0700, nmarti wrote: I'm trying to calculate the percent change for a time-series variable. Basically the first several observations often look like this, x - c(100, 0, 0, 150, 130, 0, 0, 200, 0) and then later in the life of the variable they're are generally

Re: [R] Dividing by 0

2008-07-25 Thread nmarti
I'm well aware these are not errors, I guess I miss-wrote. I understand your concern. Thanks for passionately looking out for my well being, you saved my life. My variable has about 10,000 elements and sometime for the first 100 to 500 elements there is lots of 0's, so I end up with lots of

Re: [R] Dividing by 0

2008-07-25 Thread Roland Rau
Hi, what about: mydata - c(1,2,3,NA, Inf, -Inf, NaN, 5, 6, 7) mydata2 - ifelse(is.na(mydata) | is.infinite(mydata), 0, mydata) mydata mydata2 nmarti wrote: I know I can use x - na.omit(x), and other forms of this, to get rid of some of these errors. I know what you

Re: [R] Dividing by 0

2008-07-25 Thread Patrick Burns
I would think that the result of your rolling calculation should be NA if there are NAs or NaNs in the window. Producing an error given NAs seems like a broken function to me. One of the main purposes of NA is so that you can do operations like what you want to do and get reasonable answers.

[R] Dividing by 0

2008-07-24 Thread nmarti
I'm trying to calculate the percent change for a time-series variable. Basically the first several observations often look like this, x - c(100, 0, 0, 150, 130, 0, 0, 200, 0) and then later in the life of the variable they're are generally no more 0's. So when I try to calculate the percent

Re: [R] Dividing by 0

2008-07-24 Thread Robert Baer
I'm trying to calculate the percent change for a time-series variable. Basically the first several observations often look like this, x - c(100, 0, 0, 150, 130, 0, 0, 200, 0) and then later in the life of the variable they're are generally no more 0's. So when I try to calculate the percent

Re: [R] Dividing by 0

2008-07-24 Thread Rolf Turner
On 25/07/2008, at 5:24 AM, Robert Baer wrote: I'm trying to calculate the percent change for a time-series variable. Basically the first several observations often look like this, x - c(100, 0, 0, 150, 130, 0, 0, 200, 0) and then later in the life of the variable they're are generally