Skip to content
Prev 68199 / 398506 Next

local average

Hi,

cut() and tapply() are your friends:
tapply(Y, cut(X, 0:100, include.lowest=TRUE), mean)

To compute medians, just pass median to tapply().  You will get NAs
where no data is found in any bin.

Cheers,
Rich
On 4/21/05, Jens Hainmueller <jens_hainmueller at ksg05.harvard.edu> wrote: