[R] how to overlook the zero in the denominator

From: Chun-Ying Lee <u9370004_at_cc.kmu.edu.tw>
Date: Wed 27 Jul 2005 - 18:51:37 EST

Dear R users:

I have two set of data, as follow:



I want to sum each (x[i]-y[i])^2/x[i] together, like:
>Sum <-sum((x[i]-y[i])^2/x[i])

[1] NaN

Because the denominator shoud not be zero. So I want to overlook those when x[i]=0, and just to sum those x[i] not equal to 0. What should I do?
Any suggestion.
Thanks in advance !!

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Jul 27 18:56:31 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:34:02 EST