Paste all combinations of a vector in R

前端 未结 1 1529
Happy的楠姐
Happy的楠姐 2020-12-07 03:03

I have a vector say:

vec = c(\"A\", \"B\", \"C\")

And I want to paste single combinations of every item in the vector to get the result

相关标签:
1条回答
  • 2020-12-07 03:34

    Try combn

     combn(vec,2, FUN=paste, collapse='')
     #[1] "AB" "AC" "BC"
    
    0 讨论(0)
提交回复
热议问题