Read ?predict, paying particular attention to the newdata argument.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnew...@dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

On August 24, 2015 2:10:11 AM PDT, CarstenH <cah...@gmx.de> wrote:
>Hi all
>
>I need to calculate the area under a curve (integral) for the following
>data
>pairs:
>
>Depth SOC      
>22.5   0.143
>28.5   0.165   
>34.5   0.131   
>37.5   0.134   
>40.5   0.138   
>43.5   0.107   
>46.5   0.132
>49.5   0.175 
>52.5   0.087   
>55.5   0.117   
>58.5   0.126   
>61.5   0.13    
>64.5   0.122   
>67.5   0.161   
>71.5   0.144   
>76.5   0.146   
>82.5   0.156   
>94.5   0.132   
>
>(Table name is P)
>
>After reading the data set I assiged the collumns by:
>
>/x <- (P$Depth)
>y <- (P$SOC)
>/
>
>and decided to make a ploynominal function (3rd order):
>
>/fitP <- lm( y~poly(x,3,raw=TRUE) )/
>
>At the next step I failed. I can plot point and function but am not
>able to
>integrate the curve between e.g. depths 20 and 80.
>
>If I try:
>/
>integrand <-function(fitP1)
>  predict(y)
>integrate(integrand, lower = 25, upper = 80)/
>
>the "Conosle" opend with the message: "Source unavailable or out of
>sync"
>and
>/
>function(fitP1)
>predict(y)
>/
>)
>
>
>Would be great if somebody could help!
>
>Thanks
>
>Carsten
>
>
>
>--
>View this message in context:
>http://r.789695.n4.nabble.com/Calculate-the-area-under-a-curve-tp4711418.html
>Sent from the R help mailing list archive at Nabble.com.
>
>______________________________________________
>R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>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 -- To UNSUBSCRIBE and more, see
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.

Reply via email to