I have 2 matrices and I want to use apply() to apply weighted median,weighted iqr and weighted quantiles for each row.I want something like:
apply(z, 1, function(x) weighted.mean(x[1:3], x[4:6]))
w<- matrix(c(3, 0, 0, 0,
0, 1, 2, 0,
1, 0, 1, 1,
0, 3, 0, 0,
0, 0, 2, 1,
1, 0, 1, 1), nrow = 6, ncol = 6)
x<- matrix(c(-1.569192, 0.0000000, 0, 0.0000000,
0.000000, -0.6744898, 0, 0.0000000,
0.000000, 0.0000000, 0, 0.0000000,
0.000000, 0.0000000, 0, 0.6744898,0,0,0,0,0,0,0,0), nrow = 6, ncol = 6)