bin {partitions} | R Documentation |
Sundry binary functionality
Description
Utilities to convert things to binary
Usage
tobin(n, len, check=TRUE)
todec(bin)
comptobin(comp, check=TRUE)
bintocomp(bin, use.C=TRUE, check=TRUE)
Arguments
n |
Integer, to be converted to binary by function |
len |
Length of the binary vector returned by function
|
bin |
Binary: a vector of |
comp |
A composition |
check |
Boolean, with default |
use.C |
Boolean, with default |
Details
These functions are not really intended for the end user; they are
used in nextcomposition()
.
Function
tobin()
converts integern
to a binary string of lengthlen
Function
todec()
converts a binary string to decimal, sotodec(tobin(n,i))==n
, providedi
is big enoughFunction
comptobin()
converts a composition to binaryFunction
bintocomp()
converts a binary string to a composition
Author(s)
Robin K. S. Hankin
References
Wikipedia contributors, 2020. “Composition (combinatorics) — Wikipedia, The Free Encyclopedia”, https://en.wikipedia.org/w/index.php?title=Composition_(combinatorics)&oldid=944285378
Examples
tobin(10,5)
todec(tobin(10,5))
comptobin(c(1,1,4))
bintocomp(c(1,1,0,0,1,1,1,1))