Calculate the number of partitions/compositions of a vector chosen
partitionsCount(v, m = NULL, ...)
compositionsCount(v, m = NULL, ...)# S3 method for default
partitionsCount(v, m = NULL, repetition = FALSE,
freqs = NULL, target = NULL, ...)
# S3 method for default
compositionsCount(v, m = NULL, repetition = FALSE,
freqs = NULL, target = NULL, weak = FALSE, ...)
# S3 method for table
partitionsCount(v, m = NULL, target = NULL, ...)
# S3 method for table
compositionsCount(v, m = NULL, target = NULL, weak = FALSE, ...)
A numerical value representing the total number of partitions/compositions.
Source vector. If v
is a positive integer, it will be converted to the sequence 1:v
. If v
is a negative integer, it will be converted to the sequence v:-1
. Only integer and numeric vectors are accepted.
Width of the partition. If m = NULL
, the length will be determined by the partitioning case (e.g. When we are generating distinct partitions of sum(1:m) >= n
).
Further arguments passed to methods.
Logical value indicating whether partitions/compositions should be with or without repetition. The default is FALSE
.
A vector of frequencies used for producing all partitions of a multiset of v
. Each element of freqs
represents how many times each element of the source vector, v
, is repeated. It is analogous to the times
argument in rep
. The default value is NULL
.
Number to be partitioned. If NULL
, max(v)
will be used.
(Compositions only) Logical flag indicating whether to allow terms of the sequence to be zero.
partitionsGeneral
, compositionsGeneral
## Same interface as partitionsGeneral
partitionsCount(25, 5)
compositionsCount(25, 5, TRUE)
partitionsCount(15, 7, TRUE)
partitionsCount(25, 5, freqs = rep(2, 25))
## Return object of class 'bigz'
partitionsCount(2500, 15, TRUE)
compositionsCount(2500, 15, TRUE)
Run the code above in your browser using DataLab