encode: Encode

Description Usage Arguments Value Examples

View source: R/encoding.R

Description

Encode a base-b array of integers into a single integer. This function uses a big-endian encoding scheme. That is, the most significant bits of the encoded integer are determined by the left-most end of the unencoded state.

Usage

1
encode(state, b = NA)

Arguments

state

Vector of the state to encode.

b

Numeric giving the base in which to encode.

Value

Numeric giving the encoded state.

Examples

1
2
3
4
5
6
7
8
9
# With specified base
encode(c(0, 0, 1), b = 2) # 1
encode(c(0, 1, 0), b = 3) # 3
encode(c(1, 0, 0), b = 4) # 16

# Without specified base
encode(c(0, 0, 2)) # 2
encode(c(0, 2, 0)) # 6
encode(c(1, 2, 1)) # 16

rinform documentation built on April 1, 2018, 12:12 p.m.