Trapezoidal rule - Hmisc [🇷 for BE/BA]

posted by d_labes  – Berlin, Germany, 2010-04-19 15:41 (5908 d 21:14 ago) – Posting: # 5168
Views: 12,087

Dear All,

just discovered in Frank Harrels library (package) Hmisc:
Area under curve defined by arbitrary x and y vectors, using trapezoidal rule and assuming x sorted appropriately

trap.rule <- function(x, y) sum(diff(x) * (y[-1] + y[-length(y)]))/2

Wow :ok:! The cream of the crop of programming art!

Regards,

Detlew

Complete thread:

UA Flag
Activity
 Admin contact
23,655 posts in 4,993 threads, 1,571 registered users;
119 visitors (0 registered, 119 guests [including 15 identified bots]).
Forum time: 12:55 CEST (Europe/Vienna)

Competence, like truth, beauty and contact lenses,
is in the eye of the beholder.    Laurence J. Peter

The Bioequivalence and Bioavailability Forum is hosted by
BEBAC Ing. Helmut Schütz
HTML5