[R] Dividing by 0

Roland Rau roland.rproject at gmail.com
Fri Jul 25 21:23:38 CEST 2008


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



More information about the R-help mailing list