Re: [R] Dividing by 0

From: Roland Rau <roland.rproject_at_gmail.com>
Date: Fri, 25 Jul 2008 15:23:38 -0400

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 mean, I think, but I would not call it errors. Rather, it is following a standard specification. Check
?is.finite

for further information (and the links therein).

Hope this helps,
Roland



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:26:36 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 - 19:32:30 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.

list of date sections of archive