Learn R Programming

dinamic (version 1.0.1)

recodeBinary: Recode binary vectors

Description

Recode binary vectors

Usage

recodeBinary(binary.vec, k)

Value

A binary vector of length m that contains a single contiguous string of 1's, namely the string that contains the 1 in the kth position of binary.vec.

Arguments

binary.vec

A binary vector of length m (>= 1) whose kth entry is 1.

k

A positive integer.

Details

This function is called internally by peeling.

Examples

Run this code
test = c(1, 0, 0, 1, 1, 0, 0, 1, 0)
recodeBinary(test, 5)   
#Returns (0, 0, 0, 1, 1, 0, 0, 0, 0)

Run the code above in your browser using DataLab