conversion {chromstaR} | R Documentation

## Conversion of decimal and binary states

### Description

Convert combinatorial states in decimal representation to combinatorial states in binary representation and vice versa.

### Usage

    dec2bin(dec, colnames = NULL, ndigits = NULL)

    bin2dec(bin)

### Arguments

`dec` | A vector with whole numbers.
`colnames` | The column names for the returned matrix. If specified, `ndigits` will be the length of `colnames`.
`ndigits` | The number of digits that the binary representation should have. If unspecified, the shortest possible representation will be chosen.
`bin` | A matrix with only 0 and 1 (or TRUE and FALSE) as entries. One combinatorial state per row.

### Details

chromstaR uses decimal numbers to represent combinatorial states of peaks. These functions serve as a convenient way to get from the efficient decimal representation to a more human-readable binary representation.

### Value

A vector of integers for `bin2dec` and a matrix of logicals with one state per row for `dec2bin`.

### Functions

- `dec2bin`: Decimal to binary conversion.

- `bin2dec`: Binary to decimal conversion.

### Author(s)

Aaron Taudt

### Examples

    decimal.states <- c(0:31)
    binary.states <- dec2bin(decimal.states, colnames=paste0('mark',1:5))
    control.decimal.states <- bin2dec(binary.states)

[Package chromstaR version 1.10.0 Index]