partitions {ConsRank}R Documentation

Generate partitions of n items constrained into k non empty subsets

Description

Generate all possible partitions of n items constrained into k non empty subsets. It does not generate the universe of rankings constrained into k buckets.

Usage

partitions(n, k = NULL, items = NULL, itemtype = "L")

Arguments

n

a (integer) number denoting the number of items

k

The number of the non-empty subsets. Default value is NULL, in this case all the possible partitions are displayed

items

items: the items to be placed into the ordering matrix. Default are the first c small letters

itemtype

to be used only if items is not set. The default value is "L", namely letters. Any other symbol produces items as the first c integers

Details

If the objects to be ranked is large (>15-20) with some missing, it can take long time to find the solutions. If the searching space is limited to the space of full rankings (also incomplete rankings, but without ties), use the function BBFULL or the functions FASTcons and QuickCons with the option FULL=TRUE.

Value

the ordering matrix (or vector)

Author(s)

Antonio D'Ambrosio antdambr@unina.it

See Also

stirling2 Stirling number of second kind.

rank2order Convert rankings into orderings.

order2rank Convert orderings into ranks.

univranks Generate the universe of rankings given the input partition

Examples

X<-partitions(4,3)
#shows all the ways to partition 4 items (say "a", "b", "c" and "d" into 3 non-empty subets
 #(i.e., into 3 buckets). The Stirling number of the second kind (4,3) indicates that there
 #are 6 ways.
s2<-stirling2(4,3)$S
X2<-order2rank(X) #it transform the ordering into ranking



[Package ConsRank version 2.1.4 Index]