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.
complex_index(pat01, rev = 0, print = 0)
pat01 |
A matrix consisting of 0s or 1s |
rev |
= 1 to count the # of switches from "10" to "01". |
print |
= 1 to print the intermediate result. |
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.
A vector consisting of the # of switches for each string.
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)