How to save an object in a function
On Mar 18, 2016, at 11:18 PM, Prashobh Palakkeel <palakkeel at gmail.com> wrote:
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
X <- fn_perm_list(n, r, v)
David Winsemius Alameda, CA, USA