Search notes:

R function: combn

elems <- c('A', 'B', 'C', 'D', 'E')

combn(elems, 1)
#      [,1] [,2] [,3] [,4] [,5]
# [1,] "A"  "B"  "C"  "D"  "E"

combn(elems, 2)
#      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
# [1,] "A"  "A"  "A"  "A"  "B"  "B"  "B"  "C"  "C"  "D"
# [2,] "B"  "C"  "D"  "E"  "C"  "D"  "E"  "D"  "E"  "E"


combn(elems, 3)
#      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
# [1,] "A"  "A"  "A"  "A"  "A"  "A"  "B"  "B"  "B"  "C"
# [2,] "B"  "B"  "B"  "C"  "C"  "D"  "C"  "C"  "D"  "D"
# [3,] "C"  "D"  "E"  "D"  "E"  "E"  "D"  "E"  "E"  "E"
Github repository about-r, path: /functions/combn.R

See also

R function: choose
Index to (some) R functions

Index