[R] Averaging within a range of values
Rui Barradas
ruipbarradas at sapo.pt
Sat Jan 14 03:25:20 CET 2012
Hello,
I believe this works
res <- NULL
for(i in 1:nrow(df1)){
brk <- df1[i, 2:3]
ix <- df2$Pos >= brk$Start & df2$Pos <= brk$End
res <- rbind(res, apply(df2[ix, -1], 2, mean))
}
res
It's not very pretty but since the ranges can overlap, I'm not finding
anything prettier (without a loop).
Rui Barradas
--
View this message in context: http://r.789695.n4.nabble.com/Averaging-within-a-range-of-values-tp4291958p4294017.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list