complex_index {lazy.tools}R Documentation

Find the Complexity Index of a 0-1 String Definded as the Number of Switches from "01" to "10" to Make It Simple.

Description

Find the Complexity Index of a 0-1 String Definded as the Number of Switches from "01" to "10" to Make It Simple.

Usage

complex_index(pat01, rev = 0, print = 0)

Arguments

pat01

A matrix consisting of 0s or 1s
or a vector whose elements are strings consisting of 0s and 1s.

rev

= 1 to count the # of switches from "10" to "01".

print

= 1 to print the intermediate result.

Details

When rev == 0, if a string contains no 1's to the left of 0's it is assumed to simple.
This function returns the # of switches from "01" to "10" in order to make the string simple.

When rev == 0, the roles of 0 and 1 will be interchanged.

When the input is a matrix or data frame, complexity index of each row will be calculated.

Value

A vector consisting of the # of switches for each string.

Examples


complex_index("0101", print=1 )
pat01=matrix(c(0,1,1,0,0,1,0,1,0,0,1,1,0,0),2)
res=complex_index( pat01 )
Print(pat01,res)


[Package lazy.tools version 0.1.3 Index]