Learn R Programming

Efficient Iterators for Permutations and Combinations

Deprecation: iterpc is deprecated in favour of arrangements.

Latest Documentation: http://randy3k.github.io/iterpc

Github: https://github.com/randy3k/iterpc

A collection of iterators for generating permutations and combinations with or without replacement; with distinct items or non-distinct items (multiset). The generated sequences are in lexicographical order (dictionary order). The algorithms to generate permutations and combinations are memory efficient. These iterative algorithms enable users to process all sequences without putting all results in the memory at the same time. The algorithms are written in C/C++ for faster performances.

Credit

Thank Martin Broadhurst and Alistair Israel for their algorithms. Alistair Israel has a very nice article on an algorithm to generate k-permutation.

Installation

If you want to install the latest development version, you can use devtools:

devtools::install_github("randy3k/iterpc")

or you can install the stable version via CRAN

install.packages("iterpc")

Copy Link

Version

Install

install.packages('iterpc')

Monthly Downloads

2,643

Version

0.4.2

License

GPL-2

Maintainer

Randy Lai

Last Published

January 10th, 2020

Functions in iterpc (0.4.2)

getnext

Get the next permutation(s)/combination(s) for a iterator
multichoose

Calculate multinomial coefficient
getlength

Get the length for a iterator
getall

Get all permutations/combinations for a iterator
iter_wrapper

Wrap iterpc objects by iterators::iter
np_multiset

Calculate the number of r-permutations of a multiset
nc_multiset

Calculate the number of r-combinations of a multiset
iterpc

Efficient Iterator for Permutations and Combinations
getcurrent

Get the current element of a iterator