..or do I have to give
P.nk <- factorial(n) / factorial(n-k)
or
P.nk <- choose(n,k) * factorial(k)
Thank you.
..or do I have to give
P.nk <- factorial(n) / factorial(n-k)
or
P.nk <- choose(n,k) * factorial(k)
Thank you.
I don't know of any existing function. Your first suggestion will fail with large n. Your second idea should work fine when written as a function:
perm <- function(n,k){choose(n,k) * factorial(k)}
Then perm(500,2)
will give 249500 for example.
I think the gregmisc package provides these functions.
library(gregmisc)
permutations(n=4,r=4)
Mailing list reference: [R] permutation