From: Tuszynski, Jaroslaw W. <JAROSLAW.W.TUSZYNSKI_at_saic.com>

Date: Tue 02 Aug 2005 - 23:22:57 EST

Date: Tue 02 Aug 2005 - 23:22:57 EST

How about:

trapz = function(x, y)

{ # computes the integral of y with respect to x using trapezoidal
integration.

idx = 2:length(x)

return (as.double( (x[idx] - x[idx-1]) %*% (y[idx] + y[idx-1])) / 2)
}

Jarek

====================================================\======= Jarek Tuszynski, PhD. o / \ Science Applications International Corporation <\__,| (703) 676-4192 "> \ Jaroslaw.W.Tuszynski@saic.com ` \

-----Original Message-----

From: r-help-bounces@stat.math.ethz.ch

[mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Renuka Sane
Sent: Tuesday, August 02, 2005 8:51 AM

To: r-help@stat.math.ethz.ch

Subject: [R] question on graphs and finding area under a curve

-- Renuka Sane http://www.nyx.net/~rsane [[alternative HTML version deleted]] ______________________________________________ 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.htmlReceived on Tue Aug 02 23:32:28 2005

*
This archive was generated by hypermail 2.1.8
: Sun 23 Oct 2005 - 15:01:08 EST
*