From: nmarti <nate318i_at_yahoo.com>

Date: Fri, 25 Jul 2008 08:42:09 -0700 (PDT)

*>
*

> The foregoing response exemplifies what I think is the ***RIGHT*** way

*> to answer wrong-headed questions on this list. ``What you want to do
*

*> makes no sense, but if you insist on doing it, here's how.''
*

*>
*

*> To my mind, wanting the result of division by zero to be zero *in
*

*> general*
*

*> is nothing short of idiotic. But if someone wants to impose this
*

*> convention
*

*> in his or her own calculations, well that's their ``democratic right''.
*

*> And Robert Baer clearly and succinctly (and more tactfully than I) makes
*

*> this clear.
*

*>
*

*> A similar style of response would have been appropriate in respect of
*

*> the
*

*> fooferaw that has been going on, on this mailing list on the topic of
*

*> ``Coefficients of Logistic Regression from bootstrap - how to get
*

*> them?''
*

*>
*

*> cheers,
*

*>
*

*> Rolf Turner
*

*>
*

*> ######################################################################
*

*> Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
*

*>
*

*> ______________________________________________
*

*> R-help_at_r-project.org mailing list
*

*> https://stat.ethz.ch/mailman/listinfo/r-help
*

*> PLEASE do read the posting guide
*

*> http://www.R-project.org/posting-guide.html
*

*> and provide commented, minimal, self-contained, reproducible code.
*

*>
*

*>
*

Date: Fri, 25 Jul 2008 08:42:09 -0700 (PDT)

Rolf Turner-3 wrote:

*>
**>
*

> 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 >>> no more >>> 0's. So when I try to calculate the percent change from one >>> observation to >>> the next, I end up with a lot of NA/Nan/INF, and sometimes 0's >>> which is what >>> I want, in the beginning. >>> >>> I know I can use x <- na.omit(x), and other forms of this, to get >>> rid of >>> some of these errors. But I would rather use some kind of >>> function that >>> would by defult give a 0 while dividing by zero so that I don't >>> lose the >>> observation, which is what happens when I use na.omit. >>> >> >> Well, this is not an error but proper behavior in the world of math >> that I know. >> >> However, to get what you want you could try >> x=(100-0)/0 >> if(!is.finite(x))x=0 >> x

> The foregoing response exemplifies what I think is the ***RIGHT*** way

-- View this message in context: http://www.nabble.com/Dividing-by-0-tp18632469p18654242.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help_at_r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.Received on Fri 25 Jul 2008 - 19:10:07 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Fri 25 Jul 2008 - 20:34:15 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*