So, In a string containing multiple 1\'s,
Now, it is possible that, the number
\'1\'
appears at several positions, let\'s say, at m
Perhaps the following route will help:
Convert string to a vector of integers characters
v <- as.integer(strsplit(s, "")[[1]])
Repeatedly convert this vector to matrices of varying number of rows...
m <- matrix(v, nrow=...)
...and use rle
to find relevant patterns in the rows of the matrix m
:
rle(m[1, ]); rle(m[2, ]); ...