公告
财富商城
积分规则
提问
发文
2020-06-16 03:38发布
迷人小祖宗
..or do I have to give
P.nk <- factorial(n) / factorial(n-k)
or
P.nk <- choose(n,k) * factorial(k)
Thank you.
Check out nsamp(n,k,ordered=T) in the 'prob' package
nsamp(n,k,ordered=T)
I think the gregmisc package provides these functions.
library(gregmisc) permutations(n=4,r=4)
Mailing list reference: [R] permutation
package gtools
gtools
# R version 3.5.3 install.packages("gtools") library(gtools) base::nrow(gtools::permutations(500,2))
result:
[1] 249500
also see combinations-and-permutations-in-r, permutation_with_replacement.R
another package prob:
prob
base::ncol(prob::permsn(500,2))
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.
perm(500,2)
最多设置5个标签!
Check out
nsamp(n,k,ordered=T)
in the 'prob' packageI think the gregmisc package provides these functions.
Mailing list reference: [R] permutation
package
gtools
result:
[1] 249500
also see combinations-and-permutations-in-r, permutation_with_replacement.R
another package
prob
:base::ncol(prob::permsn(500,2))
[1] 249500
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:
Then
perm(500,2)
will give 249500 for example.