我想在R studio中得到集合A <- {1,2,3,4,5,6,7,8,10}的幂集。它显示集合的前几个元素,但之后显示以下内容。
{{}, {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {10}, {1, 2}, {1, 3}, {1,
4}, {1, 5}, {1, 6}, {1, 7}, {1, 8}, {1, 10}, {2, 3}, {2, 4}, {2, 5},
{2, 6}, {2, 7}, {2, 8}, {2, 10}, {3, 4}, {3, 5}, {3, 6}, {3, 7}, {3,
8}, {3, 10}, {4, 5}, {4, 6}, {4, 7}, {4, 8}, {4, 10}, {5, 6}, {5, 7},
{5, 8}, {5, 10}, {6, 7}, {6, 8}, {6, 10}, {7, 8}, {7, 10}, {8, 10},
{1, 2, 3}, {1, 2, 4}, {1, 2, 5}, {1, 2, 6}, {1, 2, 7}, {1, 2, 8}, {1,
2, 10}, {1, 3, 4}, {1, 3, 5}, {1, 3, 6}, {1, 3, 7}, {1, 3, 8}, {1, 3,
10}, {1, 4, 5}, {1, 4, 6}, {1, 4, 7}, {1, 4, 8}, {1, 4, 10}, {1, 5,
6}, {1, 5, 7}, {1, 5, 8}, {1, 5, 10}, {1, 6, 7}, {1, 6, 8}, {1, 6,
10}, {1, 7, 8}, {1, 7, 10}, {1, 8, 10}, {2, 3, 4}, {2, 3, 5}, {2, 3,
6}, {2, 3, 7}, {2, 3, 8}, {2, 3, 10}, {2, 4, 5}, {2, 4, 6}, {2, 4, 7},
{2, 4, 8}, {2, 4, 10}, {2, 5, 6}, {2, 5, 7}, {2, 5, 8}, {2, 5, 10},
{2, 6, 7}, {2, 6, 8}, {2, 6, 10}, {2, 7, 8}, {2, 7, 10}, {2, 8, 10},
{3, 4, 5}, {3, 4, 6}, {3, 4, 7}, {3, 4, 8}, {3, 4, 10}, {3, 5, 6}, {3,
5, 7}, {3, 5, 8}, {3, 5, 10}, {3, 6, 7}, {3, 6, 8}, {3, 6, 10}, {3, 7,
8}, {3, 7, 10}, {3, 8, 10}, {4, 5, 6}, {4, 5, 7}, {4, 5, 8}, {4, 5,
10}, {4, 6, 7}, {4, 6, 8}, {4, 6, 10}, {4, 7, 8}, {4, 7, 10}, {4, 8,
10}, {5, 6, 7}, {5, 6, 8}, {5, 6, 10}, {5, 7, 8}, {5, 7, 10}, {5, 8,
10}, {6, 7, 8}, {6, 7, 10}, {6, 8, 10}, {7, 8, 10}, {1, 2, 3, 4}, {1,
2, 3, 5}, {1, 2, 3, 6}, {1, 2, 3, 7}, {1, 2, 3, 8}, {1, 2, 3, 10}, {1,
2, 4, 5}, {1, 2, 4, 6}, {1, 2, 4, 7}, {1, 2, 4, 8}, {1, 2, 4, 10}, {1,
2, 5, 6}, {1, 2, 5, 7}, {1, 2, 5, 8}, {1, 2, 5, 10}, {1, 2, 6, 7}, {1,
2, 6, 8}, {1, 2, 6, 10}, {1, 2, 7, 8}, {1, 2, 7, 10}, {1, 2, 8, 10},
{1, 3, 4, 5}, {1, 3, 4, 6}, {1, 3, 4, 7}, {1, 3, 4, 8}, {1, 3, 4, 10},
{1, 3, 5, 6}, {1, 3, 5, 7}, {1, 3, 5, 8}, {1, 3, 5, 10}, {1, 3, 6, 7},
{1, 3, 6, 8}, {1, 3, 6, 10}, {1, 3, 7, 8}, {1, 3, 7, 10}, {1, 3, 8,
10}, {1, 4, 5, 6}, {1, 4, 5, 7}, {1, 4, 5, 8}, {1, 4, 5, 10}, {1, 4,
6, 7}, {1, 4, 6, 8}, {1, 4, 6, 10}, {1, 4, 7, 8}, {1, 4, 7, 10}, {1,
4, 8, 10}, {1, 5, 6, 7}, {1, 5, 6, 8}, {1, 5, 6, 10}, {1, 5, 7, 8},
{1, 5, 7, 10}, {1, 5, 8, 10}, {1, 6, 7, 8}, {1, 6, 7, 10}, {1, 6, 8,
10}, {1, 7, 8, 10}, {2, 3, 4, 5}, {2, 3, 4, 6}, {2, 3, 4, 7}, {2, 3,
4, 8}, {2, 3, 4, 10}, {2, 3, 5, 6}, {2, 3, 5, 7}, {2, 3, 5, 8}, {2, 3,
5, 10}, {2, 3, 6, 7}, {2, 3, 6, 8}, {2, 3, 6, 10}, {2, 3, 7, 8}, {2,
3, 7, 10}, {2, 3, 8, 10}, {2, 4, 5, 6}, {2, 4, 5, 7}, {2, 4, 5, 8},
{2, 4, 5, 10}, {2, 4, 6, 7}, {2, 4, 6, 8}, {2, 4, 6, 10}, {2, 4, 7,
8}, {2, 4, 7, 10}, {2, 4, 8, 10}, {2, 5, 6, 7}, {2, 5, 6, 8}, {2, 5,
6, 10}, {2, 5, 7, 8}, {2, 5, 7, 10}, {2, 5, 8, 10}, {2, 6, 7, 8}, {2,
6, 7, 10}, {2, 6, 8, 10}, {2, 7, 8, 10}, {3, 4, 5, 6}, {3, 4, 5, 7},
{3, 4, 5, 8}, {3, 4, 5, 10}, {3, 4, 6, 7}, {3, 4, 6, 8}, {3, 4, 6,
10}, {3, 4, 7, 8}, {3, 4, 7, 10}, {3, 4, 8, 10}, {3, 5, 6, 7}, {3, 5,
6, 8}, {3, 5, 6, 10}, {3, 5, 7, 8}, {3, 5, 7, 10}, {3, 5, 8, 10}, {3,
6, 7, 8}, {3, 6, 7, 10}, {3, 6, 8, 10}, {3, 7, 8, 10}, {4, 5, 6, 7},
{4, 5, 6, 8}, {4, 5, 6, 10}, {4, 5, 7, 8}, {4, 5, 7, 10}, {4, 5, 8,
10}, {4, 6, 7, 8}, {4, 6, 7, 10}, {4, 6, 8, 10}, {4, 7, 8, 10}, {5, 6,
7, 8}, {5, 6, 7, 10}, {5, 6, 8, 10}, {5, 7, 8, 10}, {6, 7, 8, 10}, {1,
2, 3, 4, 5}, {1, 2, 3, 4, 6}, {1, 2, 3, 4, 7}, {1, 2, 3, 4, 8}, {1, 2,
3, 4, 10}, {1, 2, 3, 5, 6}, {1, 2, 3, 5, 7}, {1, 2, 3, 5, 8}, {1, 2,
3, 5, 10}, {1, 2, 3, 6, 7}, {1, 2, 3, 6, 8}, {1, 2, 3, 6, 10}, {1, 2,
3, 7, 8}, {1, 2, 3, 7, 10}, {1, 2, 3, 8, 10}, {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2, 3, 4, 8, 10}, {2, 3,
5, 6, 7}, {2, 3, 5, 6, 8}, {2, 3, 5, 6, 10}, {2, 3, 5, 7, 8}, {2, 3,
5, 7, 10}, {2, 3, 5, 8, 10}, {2, 3, 6, 7, 8}, {2, 3, 6, 7, 10}, {2, 3,
6, 8, 10}, {2, 3, 7, 8, 10}, {2, 4, 5, 6, 7}, {2, 4, 5, 6, 8}, {2, 4,
5, 6, 10}, {2, 4, 5, 7, 8}, {2, 4, 5, 7, 10}, {2, 4, 5, 8, 10}, {2, 4,
6, 7, 8}, {2, 4, 6, 7, 10}, {2, 4, 6, 8, 10}, {2, 4, 7, 8, 10}, {2, 5,
6, 7, 8}, {2, 5, 6, 7, 10}, {2, 5, 6, 8, 10}, {2, 5, 7, 8, 10}, {2, 6,
7, 8, 10}, {3, 4, 5, 6, 7}, {3, 4, 5, 6, 8}, {3, 4, 5, 6, 10}, {3, 4,
5, 7, 8}, {3, 4, 5, 7, 10}, {3, 4, 5, 8, 10}, {3, 4, 6, 7, 8}, {3, 4,
6, 7, 10}, {3, 4, 6, 8, 10}, {3, 4, 7, 8, 10}, {3, 5, 6, 7, 8}, {3, 5,
6, 7, 10}, {3, 5, 6, 8, 10}, {3, 5, 7, 8, 10}, {3, 6, 7, 8, 10}, {4,
5, 6, 7, 8}, {4, 5, 6, 7, 10}, {4, 5, 6, 8, 10}, {4, 5, 7, 8, 10}, {4,
6, 7, 8, 10}, {5, 6, 7, 8, 10}, <<set(6)>>, <<set(6)>>, <<set(6)>>,
<<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>,
<<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>,
<<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>,
<<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>,
<<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>,
<<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>,
<<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>,
<<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>,
<<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>,
<<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>,
<<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>,
<<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>,
<<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>,
<<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>,
<<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>,
<<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>, <<set(6)>>,
<<set(6)>>, <<set(7)>>, <<set(7)>>, <<set(7)>>, <<set(7)>>,
<<set(7)>>, <<set(7)>>, <<set(7)>>, <<set(7)>>, <<set(7)>>,
<<set(7)>>, <<set(7)>>, <<set(7)>>, <<set(7)>>, <<set(7)>>,
<<set(7)>>, <<set(7)>>, <<set(7)>>, <<set(7)>>, <<set(7)>>,
<<set(7)>>, <<set(7)>>, <<set(7)>>, <<set(7)>>, <<set(7)>>,
<<set(7)>>, <<set(7)>>, <<set(7)>>, <<set(7)>>, <<set(7)>>,
<<set(7)>>, <<set(7)>>, <<set(7)>>, <<set(7)>>, <<set(7)>>,
<<set(7)>>, <<set(7)>>, <<set(8)>>, <<set(8)>>, <<set(8)>>,
<<set(8)>>, <<set(8)>>, <<set(8)>>, <<set(8)>>, <<set(8)>>,
<<set(8)>>, <<set(9)>>}
这是我的输出代码
library(sets)
A = set(1,2,3,4,5,6,7,8,10)
powerset_of_A = set_power(A)
powerset_of_A
我希望代码能够完全显示powerset的子集,而不用<<set(value)>>元素替换剩余的set
3条答案
按热度按时间qco9c6ql1#
这需要一些挖掘,但是你可以为
sets
传递一个limit
参数给print
:我发现这个是因为...
sets:::print.set
调用sets:::format.set
,sets:::format.set
调用sets:::.format_set_or_tuple
,sets:::.format_set_or_tuple
调用sets:::LABELS
,正是这个LABELS
函数接受limit
参数。幸运的是,...
在整个过程中使用得当,因此参数是从print
一直到LABELS
。u91tlkcl2#
替换较长的集合是
set
的print()
方法的一部分。实际数据不受此影响。set的print方法有一个limit
参数。将其设置为10,输出将不会被截断。或者:您可以更改对象的类以使用另一个print方法:
as.list()
是一个选项。e5nqia273#
我认为你看到的输出是一个截断的版本。这是因为R试图在控制台中显示对象的用户友好表示,而不会压倒显示。
要获得完整的输出,也许你可以将powerset转换为列表,然后单独打印每个子集。
下面是一个简单的例子:
运行上面的代码将分别打印每个子集,从而确保您看到完整的powerset而不会被截断。