combn(x, m, FUN = NULL, simplify = TRUE, ...)
x | normally an integer n, in which case combinations of elements from 1:n are returned. Otherwise x is a vector, and elements of the vector are returned. |
m | the number of elements in each combination. |
FUN | the function to apply to each combination. If NULL, the combinations themselves are returned, one in each column of the result. |
simplify | A logical value. if FALSE, the results are returned as a list, one combination or function value in each element. If TRUE (the default), if possible, the results are simplified to a matrix or an array. |
... | any optional argument to pass to FUN. |
combn(5, 3) combn(letters[1:5], 3) combn(5, 3, simplify = FALSE) combn(5, 3, FUN = max) combn(5, 3, FUN = range) combn(5,3, FUN = diag) # produces an arraycombn(5,3, FUN = diag, simplify = FALSE, nrow = 2) # list of 2x2 matrices with some warnings