[R] How to save an object in a function
Prashobh Palakkeel
palakkeel at gmail.com
Sat Mar 19 07:18:40 CET 2016
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]]
More information about the R-help
mailing list