This is the code for permutations from the package "gtools" fn_perm_list <- function (n, r, v = 1:n) { if (r == 1) matrix(v, n, 1) else if (n == 1) matrix(v, 1, r) else { X <- NULL for (i in 1:n) X <- rbind(X, cbind(v[i], fn_perm_list(n - 1, r - 1, v[-i]))) X
} } How to save X as an object(matrix) while running the function with regards, Prashobh [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.