[R] area under the curve
Rolf Turner
rolf.turner at xtra.co.nz
Tue Aug 16 00:43:44 CEST 2011
On 16/08/11 05:07, Mariana Varela wrote:
> HI there, I have been trying to use a code posted on R help to be able to calculate area under the curve for complicated data points and there seems to be an issue with the code: no "b" object found. I am not a good R user and can't find were the problem is. Any help? Thanks!!
> This is the code ( as a test run I gave it this info because I know the answer:
> x<-seq(1:50)
> y<-seq(1:50)
There is nothing wrong with the code, except for a few typographical errors
in the code *as you posted it*. (A missing "^" and a missing line feed.)
How did you actually call simp()? Your posting does not show this.
With your x and y (why wrap the 1:50 up in seq()? just x <- 1:50 is
what is required) I get
> simp(y,x=x)
[1] 1249.5
(which is the right answer! :-) )
cheers,
Rolf Turner
More information about the R-help
mailing list