I'm trying to create a list of permutations of a list, such that, for example, perms(list("a", "b", "c")) returnslist(list("a", "b", "c"), list("a", "c", "b"), list("b", "a", "c"), list("b", "c", "a"), list("c", "a", "b"), list("c", "b", "a"))我不确定如何进行,任何帮助将不胜感激.I'm not sure how to proceed, any help would be greatly appreciated.推荐答案combinat::permn 将完成这项工作:> library(combinat)> permn(letters[1:3])[[1]][1] "a" "b" "c"[[2]][1] "a" "c" "b"[[3]][1] "c" "a" "b"[[4]][1] "c" "b" "a"[[5]][1] "b" "c" "a"[[6]][1] "b" "a" "c"请注意,如果元素很大,则计算量很大.Note that calculation is huge if the element is large. 这篇关于在 R 中生成列表的所有不同排列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-20 10:27