On 29 May 2002 at 12:03, Alesia Ferguson wrote:
> Using S-plus 6 on Windows ME
>
> I looking for an equivalent function to trapz() found in Matlab to
> implement in S-plus 6
I do not know exact function of trapz() but from the subject and
F.Harrell's reply this remainds me what I use for numeric
integration to find out area of a peak
integ1<-function (x,y,dm=-Inf,hm=+Inf)
{
if(dm==-Inf)dm<-min(x)
if(hm==+Inf)hm<-max(x)
vyber<-x<=hm&x>=dm
l<-length(x[vyber])
v<-diff(x[vyber])
z<-y[vyber][1:l-1]+y[vyber][2:l]
o<-z*v/2
osum<-sum(o)
o1<-
(y[x==min(x[vyber])]+y[x==max(x[vyber])])*(max(x[vyber])-
min(x[vyber]))/2
cista<-osum-o1
return(c(osum,cista))
}
"osum" is an area below part of a curve to y=0 and "cista" is an
area to baseline given by lowest y values in requred range.
The code works in R, for S+ it will need some minor language
modification.
>
> Thank you
> Alesia
>
> --------------------------------------------------------------------
> This message was distributed by s-news@lists.biostat.wustl.edu. To
> unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
> the BODY of the message: unsubscribe s-news
Petr Pikal
petr.pikal@precheza.cz
p.pik@volny.cz
|