Say your cut points are -1, 0, 1, and 2, and you are interested in the average of the sections that mimic the standard Normal.
samp <- rnorm(1e5) (res <- tapply(samp, findInterval(samp, c( -1, 0, 1, 2)), mean) ) # 0 1 2 3 4 #-1.5164151 -0.4585519 0.4608587 1.3836470 2.3824633
Please note that labeling may be improved. One of the improvements could be:
names(res) <- paste("[", c(-Inf, -1, 0, 1, 2, Inf)[-6], " , ", c(-Inf, -1, 0, 1, 2, Inf)[-1], ")", sep="") > res [-Inf , -1) [-1 , 0) [0 , 1) [1 , 2) [2 , Inf) -1.5278185 -0.4623743 0.4621885 1.3834442 2.3835116
source share