Let us say I have a Rle like so, of length 10:
b = rle(c("H", "T", "T", "H", "H", "H", "H", "H", "T", "H"))
How can I get the length of this object without using inverse.rle
?
length(inverse.rle(b))
# 10
I have some sparse Rles representing chromosomes and they can have a length of hundreds of millions so I would rather not use inverse.
akruns answer does not work on my data:
> a
$ mydata
numeric-Rle of length 57442693 with 12471 runs
Lengths: 2709826 100 31062 100 ... 2 232 100 47
Values : 0 1 0 1 ... 1 0 1 0
> a$lengths
NULL