Hi, I want to know the area under a curve, which is not given as a function, but as values in a time series. It is not a smooth curve, but switches often between positive values and zero (the values describe the moisture in the soil over a year, one entry is one day). I already tried area.between.curves, but got only 0 as result. I guess, it doesn't work because of these multiple changes between 0 and positive values (most of the time, the values are 0 and in the certain case I tested, the positive values were only on single days; but for other values positive values last longer) I hope, someone can help me! THank you! -- View this message in context: http://r.789695.n4.nabble.com/Calculate-area-under-a-curve-tp2275283p2275283.html Sent from the R help mailing list archive at Nabble.com.
simp() in the StreamMetabolism package may do the trick. I have used this on time series of chemical constituent masses. hth, Stephen Sefick On Thu, Jul 1, 2010 at 9:56 AM, suse <meyfarth at uni-potsdam.de> wrote:> > Hi, > > I want to know the area under a curve, which is not given as a function, but > as values in a time series. It is ?not a smooth curve, but switches often > between positive values and zero (the values describe the moisture in the > soil over a year, one entry is one day). I already tried > area.between.curves, but got only 0 as result. I guess, it doesn't work > because of these multiple changes between 0 and positive values (most of the > time, the values are 0 and in the certain case I tested, the positive values > were only on single days; but for other values positive values last longer) > I hope, someone can help me! > > THank you! > -- > View this message in context: http://r.789695.n4.nabble.com/Calculate-area-under-a-curve-tp2275283p2275283.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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. >-- Stephen Sefick ____________________________________ | Auburn University | | Department of Biological Sciences | | 331 Funchess Hall | | Auburn, Alabama | | 36849 | |___________________________________| | sas0025 at auburn.edu | | http://www.auburn.edu/~sas0025 | |___________________________________| Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis
On Jul 1, 2010, at 10:56 AM, suse wrote:> > Hi, > > I want to know the area under a curve, which is not given as a > function, but > as values in a time series. It is not a smooth curve, but switches > often > between positive values and zero (the values describe the moisture > in the > soil over a year, one entry is one day). I already tried > area.between.curves, but got only 0 as result. I guess, it doesn't > work > because of these multiple changes between 0 and positive values > (most of the > time, the values are 0 and in the certain case I tested, the > positive values > were only on single days; but for other values positive values last > longer) > I hope, someone can help me!?approxfun # will return a function that you can pass to integrate -- David Winsemius, MD West Hartford, CT
The mean values theorem of integration (which I think typifies the differences in thinking between mathematicians and statisticians) says that the integral from a to b is equal to the average value of the curve between a and b times the distance from a to b (b - a). I would be interested in how similar the areas computed using the other methods suggested compare to just averaging your data and multiplying by the distance. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of suse > Sent: Thursday, July 01, 2010 8:57 AM > To: r-help at r-project.org > Subject: [R] Calculate area under a curve > > > Hi, > > I want to know the area under a curve, which is not given as a > function, but > as values in a time series. It is not a smooth curve, but switches > often > between positive values and zero (the values describe the moisture in > the > soil over a year, one entry is one day). I already tried > area.between.curves, but got only 0 as result. I guess, it doesn't work > because of these multiple changes between 0 and positive values (most > of the > time, the values are 0 and in the certain case I tested, the positive > values > were only on single days; but for other values positive values last > longer) > I hope, someone can help me! > > THank you! > -- > View this message in context: http://r.789695.n4.nabble.com/Calculate- > area-under-a-curve-tp2275283p2275283.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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.