number2binary: Convert an integer to fixed-length binary format

Description Usage Arguments Value Author(s) See Also Examples

View source: R/number2binary.R

Description

This is a wrapper function around intToBits that returns a bit code in fixed-length integer format. The code is based on an SO post by Paul Hiemstra, see https://stackoverflow.com/questions/12088080/how-to-convert-number-into-binary-vector.

Usage

1
number2binary(number, no_bits, to_char = FALSE)

Arguments

number

An integer to be converted.

no_bits

integer. The desired length of the returned bit code.

to_char

logical. If TRUE, the resulting bit code is returned as merged string.

Value

A bit code in fixed-length integer format or, if to_char, a single character.

Author(s)

Florian Detsch

See Also

intToBits.

Examples

1
2
3
number2binary(10)
number2binary(10, no_bits = 4)
number2binary(10, no_bits = 4, to_char = TRUE)

environmentalinformatics-marburg/Rsenal documentation built on Sept. 23, 2018, 5:17 a.m.