Hello everybody,

Without any loop and any package,

I would like to return N products of M rows in a matrix A :

Today, I managed to do it with a loop :

B <- matrix(NA, ncol = ncol(A), nrow = 0)
for (i in 1 : N) B <- rbind(B, apply(A[sample(1 : nrow(A), M, replace = T),
], 2, prod))

Do you have a solution ?

Thank you in advance !

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to