partitions

0th

Percentile

Partitions of an Integer

Provides fast algorithms for generating integer partitions.

Usage
partitions(n, max = 0, length = 0, perm = FALSE, fill = FALSE,
  equal = T)
Arguments
n

positive integer.

max

maximum integer in the partitions.

length

maximum number of elements in the partitions.

perm

logical. Permute partitions?

fill

logical. Fill partitions with zeros to match length?

equal

logical. Return only partition of n? If FALSE, partitions of all integers less or equal to n are returned.

Value

list of partitions, or data.frame if length>0 and fill=TRUE.

Aliases
  • partitions
Examples
# NOT RUN {
# partitions of 4
partitions(4)

# partitions of 4 and permute
partitions(4, perm = TRUE)

# partitions of 4 with max element 2
partitions(4, max = 2)

# partitions of 4 with 2 elements
partitions(4, length = 2)

# partitions of 4 with 3 elements, fill with zeros
partitions(4, length = 3, fill = TRUE)

# partitions of 4 with 3 elements, fill with zeros and permute
partitions(4, length = 3, fill = TRUE, perm = TRUE)

# partitions of all integers less or equal to 3 
partitions(3, equal = FALSE) 

# partitions of all integers less or equal to 3, fill to 2 elements and permute
partitions(3, equal = FALSE, length = 2, fill = TRUE, perm = TRUE) 

# }
Documentation reproduced from package calculus, version 0.1.0, License: GPL-3

Community examples

Looks like there are no examples yet.