Skip to content
Prev 276186 / 398506 Next

how to count number of occurrences

Hi,
On Wed, Nov 2, 2011 at 12:54 PM, Sl K <s.karmv at gmail.com> wrote:
Using dput() to provide reproducible data would be nice, but failing that
here's a simple example with sample data:
Run Length Encoding
  lengths: int [1:6] 1 1 3 1 5 2
  values : chr [1:6] "x" "y" "x" "y" "x" "y"

You can use the values component of the list returned by rle to subset the
lengths component of the list to get only the x values if that's what you
need to end up with.
[1] 1 3 5