Solved – How to find the number of runs
How to find the number of runs in the following aaaabbabbbaabba bbaaaaaabbbbaaaaaaa Best Answer If you want do this in R, check out the rle function. For example: > ext <- function(x) {strsplit(x, "")[[1]]} > x <- ext("aaaabbabbbaabba") > y <- ext("bbaaaaaabbbbaaaaaaa") > length(rle(x)$lengths) [1] 7 > length(rle(y)$lengths) [1] 4 See also this related question … Read more