Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私はRでプログラムを作成しようとしています。このプログラムは、ベクトルが与えられると、そのベクトルから要素のすべての可能なタプルを返します。
例:tuples(c('a'、'b'、'c'))= c('a'、'b'、'c'); タクシー'); c('a'、'c')、c('b'、'c'); c('a'); c('b'); c('c')
ベクトルのリストを返す必要があると思います。
参考までに、Stataで同様の機能を実行するプログラムを次に示します。
あなたが使用することができますcombn:
combn
x <- 1:3 unlist(lapply(x, function(n) combn(x, n, simplify=FALSE)), recursive=FALSE)