rspacingcombn

Simplify output for combn function to remove spaces and row and column markers


I would like to take a data set like the one below generated using the combn function:

https://i.ibb.co/r0qSmYV/example.jpg

and have it print

1111112223
2223343344
3454544555

the current solutions I have tried are trimws() and gsub(). Any help will be greatly appreciated.


Solution

  • libary(tidyverse)
    as.data.frame(combn(1:5, 3)) |>  rowwise() |> 
    mutate(
      txt = paste0(c_across(),collapse = "")
    ) |> pull(txt) |> cat(fill=1L)