R - 一行代码从向量中生成两两组合并且生成tibble

应用场景:一共8个子网络,生成两个子网络之间的连接强度.

mod.label = c('SUB', 'VN', 'SMN', 'DAN', 'VAN', 'LM', 'FPN', 'DMN')

网络组合有C(8,2)=4*7=28种
预期结果


在tidyverse下代码其实很简单
combinat::combn(mod.label, 2) %>% t() %>% as_tibble() %>% setNames(c('mod1', 'mod2'))

Ref
https://www.geeksforgeeks.org/calculate-combinations-and-permutations-in-r/

你可能感兴趣的:(R - 一行代码从向量中生成两两组合并且生成tibble)