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

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759406449, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/R/functions/choose(72): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78