# wrapper to put combn() output into a tibble (i.e. dataframe with nice printing options)
library(tidyverse)
combn_ttibble <- function(x, m = 2, fun = NULL, simplify = TRUE, ...){
combn(x, m = m, FUN = fun, simplify = simplify, ...) %>%
t() %>%
tibble::as_tibble()
}
combn_ttibble(colnames(iris))
#> Warning: `as_tibble.matrix()` requires a matrix with column names or a `.name_repair` argument. Using compatibility `.name_repair`.
#> This warning is displayed once per session.
#> # A tibble: 10 x 2
#> V1 V2
#> <chr> <chr>
#> 1 Sepal.Length Sepal.Width
#> 2 Sepal.Length Petal.Length
#> 3 Sepal.Length Petal.Width
#> 4 Sepal.Length Species
#> 5 Sepal.Width Petal.Length
#> 6 Sepal.Width Petal.Width
#> 7 Sepal.Width Species
#> 8 Petal.Length Petal.Width
#> 9 Petal.Length Species
#> 10 Petal.Width Species
Created on 2020-05-31 by the reprex package (v0.3.0)