encode4int {adana}R Documentation

Convert integer vectors to binary vectors

Description

The function encode4int converts each element in a given integer vector to a binary number.

Usage

encode4int(x, M, ...)

Arguments

x

A vector containing integer numbers

M

A vector containing the number of bits in the binary representation of each integer variable.

...

Further arguments passed to or from other methods.

Details

This function converts each element in the integer vector passed with the x argument to a binary number. The M argument refers to the number of bits in the binary representation of each integer variable.

Value

A vector of binary representation of input vector

Author(s)

Zeynel Cebeci & Erkut Tekeli

See Also

decode4int, calcM

Examples

n = 5
lb = c(0, 0, 0)
ub = c(10, 10, 10)
set.seed(1)
intmat = matrix(round(runif(3*n, lb, ub)), nr=n, nc=3) 
colnames(intmat) = paste0("v",1:3)
head(intmat)
M = calcM(ub)
M
binmat = matrix(NA, nrow=n, ncol=sum(M))
for(i in 1:n)
  binmat[i,] = encode4int(intmat[i,], M=M)
head(binmat)

[Package adana version 1.1.0 Index]