Trapezoidal rule - Hmisc [🇷 for BE/BA]

posted by d_labes  – Berlin, Germany, 2010-04-19 15:41 (5901 d 11:12 ago) – Posting: # 5168
Views: 12,067

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,654 posts in 4,992 threads, 1,571 registered users;
133 visitors (0 registered, 133 guests [including 13 identified bots]).
Forum time: 02:54 CEST (Europe/Vienna)

Always listen to experts.
They’ll tell you what can’t be done and why.
Then do it.    Robert A. Heinlein

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