From: Christoph Buser <buser_at_stat.math.ethz.ch>

Date: Wed 27 Jul 2005 - 19:09:53 EST

Christoph Buser <buser@stat.math.ethz.ch> Seminar fuer Statistik, LEO C13

http://stat.ethz.ch/~buser/

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 19:14:44 2005

Date: Wed 27 Jul 2005 - 19:09:53 EST

What about

x<-c(0,0,0.28,0.55,1.2,2,1.95,1.85, 1.6,0.86,0.78,0.6,0.21,0.18) y<-c(0,0,0,0.53,1.34,1.79,2.07,1.88, 1.52,0.92,0.71,0.55,0.32,0.19)

sum(((x-y)^2/x)[x!=0])

Regards,

Christoph Buser

Christoph Buser <buser@stat.math.ethz.ch> Seminar fuer Statistik, LEO C13

ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-44-632-4673 fax: 632-1228

http://stat.ethz.ch/~buser/

Chun-Ying Lee writes:

> Dear R users:

* >
** > I have two set of data, as follow:
** > x<-c(0,0,0.28,0.55,1.2,2,1.95,1.85,
** > 1.6,0.86,0.78,0.6,0.21,0.18)
** > y<-c(0,0,0,0.53,1.34,1.79,2.07,1.88,
** > 1.52,0.92,0.71,0.55,0.32,0.19)
** > i<-1:length(x)
** >
** > I want to sum each (x[i]-y[i])^2/x[i] together,
** > like:
** > >Sum <-sum((x[i]-y[i])^2/x[i])
** > >Sum
** > [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
*

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 19:14:44 2005

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