Search notes:

R function: choose

choose(k, n) calculates the number of sets with n elements than can be chosen from a set with k elements, that is the binomial coefficient
n <- 3
k <- 7

choose(k, n)
#
#  35
Github repository about-r, path: /functions/choose/choose.R

Alternative calculation

For positive natural numbers, the value of choose() can be calculated with the formula for the binomial coefficient
n <- 3
k <- 7

a <- 1
b <- 1

for (i in 1:n) {
  a <- a *  i
  b <- b * (k-i+1)
}

paste0('choose(', k, ',', n, '), alternatively calculated: ', b/a)
#
#   choose(7,3), alternatively calculated: 35
Github repository about-r, path: /functions/choose/alternative-calculation.R

See also

The R function combn.
Index to (some) R functions

Index