I have two data sets of same dimensions. I want to divide the each row of first data set into deciles based on each row of second data set and then calculate mean of each decile. I know I can do this with the help of order and loops functions. But this will take a lot of time.
x<-matrix(rnorm(10000),nrow = 100,ncol=100)
y<-matrix(rnorm(10000),nrow=100,ncol = 100)
m.r<-rep(0,100)
for (t in 1:100){
y1<-y[t,]
my_order<-order(y1,decreasing = T)
top_10<-my_order[1:10]
m.r[t]<-mean(x[t,top_10])
}
and so on next 10-20, 20-30 etc.