> On Mar 18, 2016, at 11:18 PM, Prashobh Palakkeel <palakk...@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

______________________________________________
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.

Reply via email to