Here is a simple trapezoidal rule integrator: x <- time y <- value
area <- sum(diff(x)*(y[-1]+y[-length(y)]))/2 Ravi. ---------------------------------------------------------------------------- ------- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html ---------------------------------------------------------------------------- -------- -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ptit_Bleu Sent: Tuesday, September 18, 2007 11:24 AM To: r-help@r-project.org Subject: Re: [R] RE : Must be easy, but haven't found the function (numerical integration) Thanks to all. cumsum can be helpful but the solution given by David seems to match my request. I will test it as soon as possible (before the end of the week, I hope). Have a nice end of day, Ptit Bleu. GOUACHE David wrote: > > try : > > library(Bolsatd) > ?sintegral > > or: > > library(caTools) > ?trapz > > David Gouache > Arvalis - Institut du Végétal > Station de La Minière > 78280 Guyancourt > Tel: 01.30.12.96.22 / Port: 06.86.08.94.32 > > > -----Message d'origine----- > De : Ptit_Bleu [mailto:[EMAIL PROTECTED] > Envoyé : lundi 17 septembre 2007 12:09 > À : [EMAIL PROTECTED] > Objet : [R] Must be easy,but haven't found the function (numerical > integration) > > > Hi, > > I have a data frame of 2 columns with the following types : > data$day char > data$value num > > And I plot my data with : > plot(strptime(donnees$day,format="%Y-%m-%d %H:%M:%S"),donnees$value, > type="l") > > And I'd just like to get the numerical value of the integration of this > graph. > I looked at ?integrate but, as far as I understood (that is, not very > much, > due to my poor english), it seems that it doesn't work with values in data > frame. > > Could you please help me to do this ? > > Thanks in advance, > Have a nice week, > Ptit Bleu. > -- > View this message in context: > http://www.nabble.com/Must-be-easy%2C-but-haven%27t-found-the-function-%28nu merical-integration%29-tf4465684.html#a12732936 > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@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. > > -- View this message in context: http://www.nabble.com/Must-be-easy%2C-but-haven%27t-found-the-function-%28nu merical-integration%29-tf4465684.html#a12759423 Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@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. ______________________________________________ R-help@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.