R/perm.R

perm <- 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], perm(n - 
			1, r - 1, v[-i]))) 
		X 
	} 
} 

Try the mixtools package in your browser

Any scripts or data that you put into this service are public.

mixtools documentation built on Dec. 5, 2022, 5:23 p.m.